I have two qustions :
1. I am able to initialize a new object with some other object.
Is this part of c++ ? How is it done. I dont have a constractor function that recives an ojbect type.
2. Using gcc (redhat linux 8.0) How do I use compiler options
other than c.
This is a sample code :
Code:
class test
{
public:
float f1;
char str[100];
int i;
float f2;
void show(void)
{
printf("f1 = %2.2f str = %s i = %d f2 = %2.2f\n",
f1, str, i, f2);
}
};
int main(void)
{
test t1;
t1.f1 = 3.2;
strcpy(t1.str, "my test");
t1.i = 777;
t1.f2 = -9.2;
t1.show();
test t2(t1); // Well I dont have a constractor of the type
// test::test(test t)
// Is this something done by my compiler ?
// Is this part of c++ standard ?
// Can I turn this off with acompiler option ?
t2.show(); // the same values as t1 !!!!
return(0);
}
The Makefile
Makefile
myexec: main.cpp
g++ -Wall -ggdb -Wno-parentheses −fno−elide−constructors -o $@ $^
Why do I get the error :
g++ -Wall -ggdb -Wno-parentheses −fno−elide−constructors -o myexec main.cpp
g++: −fno−elide−constructors: No such file or directory
make: *** [myexec] Error 1
Thanks all advance.