Is there ‘byte’ data type in C++?

No there is no byte data type in C++. However you could always include the bitset header from the standard library and create a typedef for byte: NB: Given that WinDef.h defines BYTE for windows code, you may want to use something other than BYTE if your intending to target Windows. Edit: In response to … Read more

Defining a struct in flex error C++

Both vector and string are in the std namespace so you should add it to the declaration of member variables of those types. Change the code to: EDIT: (thanks to Kerrek SB): also you can not define a vector of Node as a member of Node. Instead use a vector of pointers to node like so: std::vector<Node*> vecini[];

How to ensure that a std::map is ordered?

You don’t have to do anything. The map will be in ascending order according to the values of the key. Internally, the map performs a comparison between keys to order its elements. By default, it uses std::less<KEY>, which is equivalent to bool operator<(int, int) for integers. For user defined types, you have to options: Implement a bool operator<(const MyType&, … Read more

How to fix ‘std::logic_error’ what(): basic_string::_M_construct null not valid error?

The problem is the two return 0; statements in your function. The function returns a std::string, which has no constructors that accept an int as input. But, it does have a constructor that accepts a const char * pointer, which 0 is implicitly convertible to. However, constructing a std::string with a null char * pointer is undefined behavior, and your implementation has chosen to throw a std::logic_error exception that … Read more

Random number c++ in some range

You can use the random functionality included within the additions to the standard library (TR1). Or you can use the same old technique that works in plain C:

How do I call the class’s destructor?

You should not call your destructor explicitly. When you create your object on the stack (like you did) all you need is: When you create your object on the heap, you kinda need to delete your class before its destructor is called and memory is freed: (Failing to call delete on this last example will result in … Read more

Examples of good gotos in C or C++

Heres one trick I’ve heard of people using. I’ve never seen it in the wild though. And it only applies to C because C++ has RAII to do this more idiomatically.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)