Home > Back-end >  C object to establish
C object to establish

Time:10-06

The class qwe
{int a;
Public:
F1 ();
{... }
}
How to build dynamic objects of a class, the number of objects by the keyboard

CodePudding user response:

What is called dynamic objects of a class? New an array of class objects?

CodePudding user response:

How to build an array of objects, number can enter?

CodePudding user response:

With array is not very convenient, suggested a list of objects, such as TList, such as Vector to manage object pointer,

CodePudding user response:

#include
Int I, n;
The class qwe
{int a;
Public:
Void f1 (void)//input data
{cout<& lt;" Type ";
for(i=0; icin> [I] - p & gt; a; }
Void f2 (void)//output data
{the for (I=0; iCout<[I] - p & gt; a; }
};
Void main (void)
{qwe * p;
cin> n;//the number of data can be controlled
P=new qwe [n].
F1 ();
F2 ();
}
Help you a great god, and I want to finish this program, how should solve?

CodePudding user response:

Must first have a clear concept, first determine the f1 and f2 () () two function is to make it to class member functions, qwe or ordinary function, the next step is how to write these two functions
  • Related