Generic ostream issue in C++

I try to do a generic vector, but when I compile it throws this error: Undefined symbols for architecture x86_64: "operator<<(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, Vec2<int> const&)", reference...
more »

2017-01-16 23:01 (2) Answers

Any rules about underscores in filenames in C/C++?

I know that there are rules for using underscores in identifiers in C/C++. Are there any rules for using them in source code filenames? For instance, are there any restrictions against beginning or ending a filename with an underscore? Or having an ...
more »

2017-01-16 20:01 (3) Answers

iOS Clang -std -stdlib options c++11 error

I have an iOS project set up like this: I use XCode 6.1.1 clang -v says LLVM version 6.0 I use the flag -miphoneos-version-min=6.1 (I don't set -std and -stdlib) Everything's fine. When I update to -miphoneos-version-min=7.1 I have following err...
more »

2017-01-16 17:01 (0) Answers

QOCI plugin making error QT

I faced some problems when I was trying to make a QOCI driver for QT 5.7. I was folloing this Guide (How to build Qt QOCI (Oracle Database driver) on Windows with MinGW?) and it helped before the "Third try". When after the "Second try" I call ming...
more »

2017-01-15 20:01 (0) Answers

Getting all the values from a map

I have a class Student which contains a name, a private int regNo and a private map which is a store of their marks. This is the constructor. Student::Student (string const& name, int regNo):Person(name), regNo(regNo) { map<string, float&...
more »

2017-01-14 23:01 (1) Answers

Using functions within functions

Below is a piece of code I was trying to run where I have function I want to run (dN) within my main function which returns a value of type complex<double>. #include <iostream> #include <complex> #include <cmath> using namesp...
more »

2017-01-14 08:01 (3) Answers

Why doesn't %p show the full width of pointer?

If I am not mistaken, on a 64bit machine, a pointer is equivalent to a number between 0 and 2^64-1. Hence the following results: printf("%p", (void*) -1); → 0xffffffffffffffff printf("0x%lx", (uintptr_t) -1); → 0xffffffffffffffff yet wh...
more »

2017-01-13 17:01 (5) Answers

How to pass vector's cell to a function in C++?

I want to make a function that takes an object from a vector's cell and modifies it. First I need to pass this cell by reference to the function and I can not do it. void circleChoiceOne(Circle& object); vector<Shape*> shapeArr; int main()...
more »

2017-01-13 16:01 (2) Answers

how to set bitrate correctly for aac encoding OSX

I have a 1 second PCM data which I write into an AAC file successfully. However, I can not control the bitrate of the output file. Here is the configuration of my AAC codec: AudioStreamBasicDescription clientFormat = {0}; clientFormat.mSampleRate...
more »

2017-01-13 16:01 (0) Answers

C++ sort vectors time complexity

Suppose I have a vector<vector<int>> L with N vectors, and total number of ints summed across all vectors is at most M. What is the tightest time complexity of the standard C++ sort sort(L.begin(), L.end())? The vector<int> compari...
more »

2017-01-12 23:01 (2) Answers

What is Allowed in a constexpr Function?

constexpr functions are not supposed to contain: A definition of a variable of non-literal type But in this answer a lambda is defined in one: template <typename T> constexpr auto make_div(con...
more »

2017-01-12 17:01 (1) Answers

How to call generic struct in C++

I'm trying to make a class in which we can encode and decode different structs from and to a char*. I'm doing this the following way I've made an abstract generic class called CANgenericMsg with CANgenericMsg.cpp being: #include "CANgenericMsg.h" ...
more »

2017-01-12 13:01 (2) Answers

Q : std::tuples / std::array

I've always thinking std::tuple was something fancy but not really efficient. But I learned that tuple are contiguous memory because of the rules of object layout. I know that tuples are generate by inheritance and that's why we can't have dynamic t...
more »

2017-01-12 13:01 (1) Answers

Is there a way to set thread stack size using GCD?

I have a multiplatform code that has some recursive calls (running in a thread, not the main one), and in some cases the default stack size is not enough for the recursivity depth. I solve this in windows using the /STACK compiler flag: /STACK:20971...
more »

2017-01-11 18:01 (0) Answers

Sorting Optimization

I'm currently following an algorithms class and thus decided it would be good practice to implement a few of the sorting algorithms and compare them. I implemented merge sort and quick sort and then compared their run time, along with the std::sort: ...
more »

2017-01-10 23:01 (2) Answers

Function Pointer ambiguity in C++

I have two questions : Q1) Are the function names themselves pointers ?? If they are pointers , then what values are stored in them? Else if they are not pointers ,then, what are they and what values are stored in them? If we consider that functi...
more »

2017-01-10 20:01 (1) Answers

Can I get a -1 exit code using C++ on mac?

I was just wondering if it's possible to get a function in C++ on a Unix system to return -1 and not 255? I have been programming some OpenCV stuff and realised stuff wasnt working as intended. The functions I was using were meant to return -1, but ...
more »

2017-01-10 05:01 (2) Answers