What’s the difference between nexti and stepi in gdb?

stepi is more detailed than nexti. if you call sum() from main() function then doing stepi reaches you inside the sum() function, but nexti doesn’t. Below is the screenshot when you call stepi when you were at call of sum() instruction (i.e., => 0x08048403 <+40>: call 0x8048419 <sum>). The stepi instuction routes you inside the … Read more

expected identifier before string constant

You can not initialize tst_ where you declare it. This can only be done for static const primitive types. Instead you will need to have a constructor for class test1. EDIT: below, you will see a working example I did in ideone.com. Note a few changes I did. First, it is better to have the … Read more

Correct way to work with vector of arrays

You cannot store arrays in a vector or any other container. The type of the elements to be stored in a container (called the container’s value type) must be both copy constructible and assignable. Arrays are neither. You can, however, use an array class template, like the one provided by Boost, TR1, and C++0x: (You’ll … Read more

why can’t I dereference an iterator?

They are three separate errors: won’t work because end() returns a an iterator, and object is a pointer. Those are generally distinct types (A vector can use raw pointers as iterators, but not all implementations do it. Other containers require special iterator types). doesn’t work because you take the address of the returned iterator. That … Read more

Check if C++ Array is Null

Actually, when you have an array a[SIZE], you can always check: But it’s not necessary, unless you created a dynamic array (using operator new). See the other answers, I won’t delete it just because it’s accepted now. If other answer is accepted, I’ll delete this “answer”. EDIT (almost 4 years later 🙂 ) As I … Read more

What are the different versions of exec used for in C and C++?

The differences are combinations of: L vs V: whether you want to pass the parameters to the exec’ed program as L: individual parameters in the call (variable argument list): execl(), execle(), execlp(), and execlpe() V: as an array of char* execv(), execve(), execvp(), and execvpe() The array format is useful when the number of parameters … Read more

g++ “because the following virtual functions are pure” with abstract base class

Your SortedContainerImpl class has two separate Container base classes. One is virtual (via the SortedContainer class) and the other is non-virtual (via the ContainerImpl class). SortedContainerImpl has concrete implementations of Container::get_size() and Container::get(int) for the base that comes in from ContainerImpl, but not for the virtual base that comes in via SortedContainer. One way to … Read more

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