What is activation record in the context of C and C++?

An activation record is another name for Stack Frame. It’s the data structure that composes a call stack. It is generally composed of: Locals to the callee Return address to the caller Parameters of the callee The previous stack pointer (SP) value The Call Stack is thus composed of any number of activation records that … Read more

How to write C++ getters and setters

There are two distinct forms of “properties” that turn up in the standard library, which I will categorise as “Identity oriented” and “Value oriented”. Which you choose depends on how the system should interact with Foo. Neither is “more correct”. Identity oriented Here we return a reference to the underlying X member, which allows both sides of the call site … Read more

Why use a new call with a C++ ‘vector’?

Your first statement is not true. The elements in vector<someType> myVector will live until the vector is destroyed. If vector<someType> is a local variable, it will be destroyed automatically when it goes out of scope. You don’t need to call delete explicitly. Calling delete explicitly is error-prone if you take into account that because of exceptions that might be thrown, your delete statement … Read more

LNK1168: cannot open debug\file.exe for writing

I have qt project but if I edit my code, Qt creator throws out this error :-1: error: LNK1168: cannot open debug\GettingStarted.exe for writing I’m not able even to delete the debug folder (i.e. as an administrator). I have to log off and then come back. What is the problem and how can I solve … Read more

Sleep function in C++

Use std::this_thread::sleep_for: There is also the complementary std::this_thread::sleep_until. Prior to C++11, C++ had no thread concept and no sleep capability, so your solution was necessarily platform dependent. Here’s a snippet that defines a sleep function for Windows or Unix: But a much simpler pre-C++11 method is to use boost::this_thread::sleep.

How to return a string from a C++ function?

You never give any value to your strings in main so they are empty, and thus obviously the function returns an empty string. Replace: with: Also, you have several problems in your replaceSubstring function: std::string::find returns a std::string::size_type (aka. size_t) not an int. Two differences: size_t is unsigned, and it’s not necessarily the same size as an int depending on your platform (eg. on 64 bits Linux or … Read more

How do I activate C++ 11 in CMake?

As it turns out, SET(CMAKE_CXX_FLAGS “-std=c++0x”) does activate many C++11 features. The reason it did not work was that the statement looked like this: Following this approach, somehow the -std=c++0x flag was overwritten and it did not work. Setting the flags one by one or using a list method is working.

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