P
Peter Olcott
//
// Is there something wrong with my syntax for the
// Copy Constructor of an Array Element, or does
// the C++ language not support this?
//
#include <stdio.h>
#include <stdlib.h>
class X {
int Data;
public:
X() { Data = 56; };
X(const X& Y) { Data = Y.Data; }; // Copy Constructor
void Construct(const X& Y) { Data = Y.Data; };
};
int main()
{
X ABC;
X* Temp = (X*) malloc(sizeof(X) * 10);
for (int N = 0; N < 10; N++) {
// Temp[N].(ABC); // Does Not Compile
// Temp[N](ABC); // Does Not Compile
Temp[N].Construct(ABC); // Compiles and Executes Correctly
}
free(Temp);
return 0;
}
// Is there something wrong with my syntax for the
// Copy Constructor of an Array Element, or does
// the C++ language not support this?
//
#include <stdio.h>
#include <stdlib.h>
class X {
int Data;
public:
X() { Data = 56; };
X(const X& Y) { Data = Y.Data; }; // Copy Constructor
void Construct(const X& Y) { Data = Y.Data; };
};
int main()
{
X ABC;
X* Temp = (X*) malloc(sizeof(X) * 10);
for (int N = 0; N < 10; N++) {
// Temp[N].(ABC); // Does Not Compile
// Temp[N](ABC); // Does Not Compile
Temp[N].Construct(ABC); // Compiles and Executes Correctly
}
free(Temp);
return 0;
}