0

I have been learning c++ for long now but error messages always pops up when I ever I write a program on my compiler

18th Nov 2016, 10:24 AM
m johnbosco
m johnbosco - avatar
4 ответов
+ 3
Did you add headers and main? in this way #include <iostream> using namespace std; int main() { union numericUnion{ int intValue; long longValue; double doubleValue; }; numericUnion myUnion; myUnion.intValue = 3; cout << myUnion.intValue << endl; myUnion.doubleValue = 4.5; cout << myUnion.doubleValue << endl; cout << myUnion.intValue; cout << endl; return 0; }
18th Nov 2016, 10:33 AM
Freddy Alexander Paredes
Freddy Alexander Paredes - avatar
+ 2
Have you made sure to place the return 0? , As well as (;) and (:), naming the first letters of the classes with capital letters.
18th Nov 2016, 10:27 AM
Freddy Alexander Paredes
Freddy Alexander Paredes - avatar
0
yeah thanks please refer to my second question
18th Nov 2016, 10:29 AM
m johnbosco
m johnbosco - avatar
0
1. union numericUnion 2. { 3. int intValue; 4. long longValue; 5. double doubleValue; 6. }; 7. numericUnion myUnion; 8. myUnion.intValue = 3; 9. cout << myUnion.intValue << endl; 10. myUnion.doubleValue = 4.5; 11. cout << myUnion.doubleValue << endl; 12. cout << myUnion.intValue; 13. cout << endl;
18th Nov 2016, 10:29 AM
m johnbosco
m johnbosco - avatar