Quote:
|
Originally Posted by shumi
i am facing a problem while executing the below c++ code.
|
You have many misperceptions about C++:
- It is unclear whether this is meant to be a console application or an MFC application. This subforum is for generic platform agnostic programming. Microsoft-specific questions should go in the Microsoft forum.
- A standard C++ application requires a main() function. _tmain() is MFC specific.
- Standard headers require angle brackets. Header files expected to be found in the current directory are denoted by double quotes. The following:
#include "vector"
#include "iostream"
...should be replaced by:
#include <vector>
#include <iostream>
- The class definition for abc has two public sections. I can only assume that you were experimenting with relaxing member access.
- The principal problem in your code is that the objects created within the scope of your for-loop (What you are naming obj...) are destroyed at the end of the loop regardless of whether you save a pointer. The question you need to answer to yourself is why create an array of pointers? Why not create an array of objects?
-
...is incorrect syntax. If you ultimately want to use an array, you will want to use the following instead:
Lastly, when posting code,
please place a
[cpp] code tag before &
[/cpp] aftewards to both preserve formatting & color-code keywords & identifiers.