#include<iostream>
usingnamespace std;
class point{
int x, y;
public:
point (int xx, int yy) :x(xx), y(yy) {}
};
class x:public point {
point* nums;
int size;
public:
x(int a,int b):point(a,b){
}
};
int main() {
point p1(1, 1);
point p2(2, 2);
x b(p1, p2);
system("pause");
return 0;
}
how do i do when i make new X object like put few point like x(p1,p2)?
open new array ? when i call x object?
OK, I'm not understanding your design here. x inherits from point, which means that it is a point. But x also contains what appears to be an array of points. Why?
Then there's no reason for x to inherit from point. I'm guessing you haven't understood what inheritance is, or when to use it. You probably want to go back to your textbook and reread about inheritance.
Your thread title is "composition", not "inheritance". While it is good for to reread the inheritance material, you should read about composition too.
For example: http://www.learncpp.com/cpp-tutorial/102-composition/