You seem to have misunderstood what a constructor is. Your constructor doesn't "output" anything - it sets the initial state of the object, when the object is created.
So on lines 38 and 39, you create two objects, and your constructors automatically set the initial states of those objects, by setting siz allocating the array v.
Lines 40 and 41 are meaningless. Those objects are already created - you can't call the constructor on them again.
Your operator* is weird. It doesn't follow the usual semantics of a * operator at all.
i mean can we call more than one constructor using one object also want to remember the output of first constructor!
No. This is where other methods fit in.
1 2
vec v1(3);
v1.set_data(x); // does what you char* constructor does
But it would be better is your set_data method (and constructor) also took a size parameter, e.g. vec(int *a, int size)
Then you can't accidentally do
1 2 3 4
int x[3]={1,2,3};
vec v1(16);
vec.set_data(x); // problems!
vec(int *a, int size) and set_data(int *a, int size) give you the chance to check the new size against the size of the allocated array and either terminate the call or reallocate memory.
@LowestOne
the second thing you are saying i am not agre with that i have created a function like that and that is working well! here it is-
#include <iostream>
using namespace std;
int main()
{
int x,i;
cin>>x;
cout<<endl;
int a[x];
for(i=0;i<x;i++)
{
cin>>a[i];
}
for(i=0;i<x;i++){
cout<<a[i];
}
return 0;
}