using container class for c++ class objects
-
hi, i know how to count number of objects created for class using static variable, but i came to know that there is other way i.e using container class, can any one specify how it is and if any code it will be helpfull or even links are accepted.. iam attending interviews these questions asked for me.. so please helpme.. ( i answered this but dont know how to write code for this).
-
hi, i know how to count number of objects created for class using static variable, but i came to know that there is other way i.e using container class, can any one specify how it is and if any code it will be helpfull or even links are accepted.. iam attending interviews these questions asked for me.. so please helpme.. ( i answered this but dont know how to write code for this).
Have you heard about
Google
[^]? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
hi, i know how to count number of objects created for class using static variable, but i came to know that there is other way i.e using container class, can any one specify how it is and if any code it will be helpfull or even links are accepted.. iam attending interviews these questions asked for me.. so please helpme.. ( i answered this but dont know how to write code for this).
Hi, a container or collection holds/stores a number of objects. The STL library provides a number of containters.
#include <vector> class MyObject { public: MyObject() {} void DoSomething() {} }; void main() { std::vector<MyObject*> vecList; vecList.push_back(new MyObject); vecList.push_back(new MyObject); vecList.push_back(new MyObject); // count will hold the number of objects int count = vecList.size(); }
Learn from the mistakes of others, you may not live long enough to make them all yourself.
-
Have you heard about
Google
[^]? :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]hello pallini :rose:, i know google is there then y is code project is there c i can even post here right which i fell is the best so never try to answer like this is u dont feel of answering then please never ever try. ( i belive in code project and myself and also internet so no need of ur answers any more)hope u got what i mean. then if google is there then y code project is needed ? :mad:
-
hi, i know how to count number of objects created for class using static variable, but i came to know that there is other way i.e using container class, can any one specify how it is and if any code it will be helpfull or even links are accepted.. iam attending interviews these questions asked for me.. so please helpme.. ( i answered this but dont know how to write code for this).
Create a static int variable inside the class. Increment it in the constructor and decrement it in the destructor.
«_Superman_» I love work. It gives me something to do between weekends.
-
hello pallini :rose:, i know google is there then y is code project is there c i can even post here right which i fell is the best so never try to answer like this is u dont feel of answering then please never ever try. ( i belive in code project and myself and also internet so no need of ur answers any more)hope u got what i mean. then if google is there then y code project is needed ? :mad:
hawk23reddy wrote:
so never try to answer like this is u dont feel of answering then please never ever try.
And why? Is it the "hawk23reddy's rule"? Do you really think I will follow it?
hawk23reddy wrote:
i belive in code project and myself and also internet so no need of ur answers any more
I'm happy about.
hawk23reddy wrote:
hope u got what i mean.
Possibly, you know, I'm a "rather dull child"... :rolleyes:
hawk23reddy wrote:
then if google is there then y code project is needed ?
Both are useful. And they are more useful if you post the right question to the right one, I suppose. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
hawk23reddy wrote:
so never try to answer like this is u dont feel of answering then please never ever try.
And why? Is it the "hawk23reddy's rule"? Do you really think I will follow it?
hawk23reddy wrote:
i belive in code project and myself and also internet so no need of ur answers any more
I'm happy about.
hawk23reddy wrote:
hope u got what i mean.
Possibly, you know, I'm a "rather dull child"... :rolleyes:
hawk23reddy wrote:
then if google is there then y code project is needed ?
Both are useful. And they are more useful if you post the right question to the right one, I suppose. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles];) :doh: :sigh: :doh: thankx,, what to do myan iam poor in lang...
-
;) :doh: :sigh: :doh: thankx,, what to do myan iam poor in lang...
hawk23reddy wrote:
thankx,, what to do myan iam poor in lang...
I don't know. On the other hand, I'm pretty sure that your previous post was a bit rude. Anyway I don't care. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]