How can i create a new object in a class?(c++) [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.
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?

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.

EMACS regex,How to work only in the designated few lines [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.
For example, I just want it to work in the 1-10 lines, how to do it. A rookie, thanks for help.
You can use narrow-mode, and it will display only the first 10 lines, hiding the rest.

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

Should unique_ptr be used for class member pointers? [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.
Looking for some opinions on this as it's unclear in reading the C++ 11 documentation.
Absolutely. This takes care of the rule of three for you.

a counter in constructor [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.
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;
}
};