Difference between function arguments declared with & and * in C++

f2 is taking it’s arguments by reference, which is essentially an alias for the arguments you pass. The difference between pointer and reference is that a reference cannot be NULL. With the f you need to pass the address (using & operator) of the parameters you’re passing to the pointer, where when you pass by reference you just pass the parameters and … Read more

error C2995: function template has already been defined

The problem is circular dependency. set.h includes set.cpp and set.cpp includes set.h.Remember that including a file simply pastes its code. There is no need for set.cpp to know about set.h as they will be one file when compiling.Also, you shouldn’t call set.cpp a cpp file. cpp files are ones that are meant to generate object … Read more

What does “-Wall” in “g++ -Wall test.cpp -o test” do?

It’s short for “warn all” — it turns on (almost) all the warnings that g++ can tell you about. Typically a good idea, especially if you’re a beginner, because understanding and fixing those warnings can help you fix lots of different kinds of problems in your code.

How to Check the Version of my gcc?

The symlink to the 4.8.2 directory is nothing to worry about, it’s normal for the libstdc++ headers on Red Hat Enterprise Linux (and therefore CentOS) to be arranged like that. gcc –version will tell you the version of the gcc executable in your path. rpm -q libstdc++-devel will tell you the version of the package … Read more

Different ways to deallocate an array – c++

new type requires deletenew type[size] requires delete []Using one instead of the other is wrong. Btw you should not use such raw pointers like this unless you have a very good reason. Use std::vector or std::array instead. And 2D MxN arrays should generally be linearised into 1D M*N arrays, also using these containers.

C++ calling base class constructors

The short answer for this is, “because that’s what the C++ standard specifies”. Note that you can always specify a constructor that’s different from the default, like so: The default constructor of the base class is called only if you don’t specify which one to call.

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