a counter in constructor [closed] - c++

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
how to put a counter in constructor??

if you want to count the number of created objects, you can use a static (class) variable
class CountingClass {
private:
static int count;
public:
CountingClass() {
++CountingClass::count;
}
};

Related

Is map<int, list> in C++ possible? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I want to have a linkedlist for each key in the map in C++.
Yes, std::map<int, std::list<SomeType>> is possible in C++.
Have a look at ideone, which is useful for testing simple things such as this.

What is a base initializer in C++? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
My teacher asked me what a base initializer in C++ is.
Can someone of you provide me a definition?
Read up on: Initialiser Lists.
http://www.cprogramming.com/tutorial/initialization-lists-c++.html

define const list [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I do something like this and get errors from compiler
using namespace std;
///define a method for list
void method(const list<int>&lst) //ERROR here
{
//do something
}
I have no idea why
#include <list>

What is the boolean data type in C++ [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
I'm doing some exercise where I need to use a boolean. However when I try to create one as Boolean the compiler does not accept it. What is the name of the boolean type in C++?
The boolean datatype in C++ is bool as in:
bool myBool = true;

How can i create a new object in a class?(c++) [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 12 years ago.
Good evening every body~
As the title, How can i create a new object in a class? and i want to give it a number.
How can i do that?
Thank you very much~
class MyClass {
int yourNumber;
};
or what do you mean?