First off I should probably say the I use Code::Blocks as my IDE and compiler.
When I run the following programs I get a message saying "this file has not been built" and ultimately it fails to compile and run my source code.
#include <iostream>
usingnamespace std;
void pass_by_value(int a);
void pass_by_reference(int *a);
int main()
{
int x=13;
int y=13;
pass_by_value(x);
pass_by_reference(&y);
cout << "x is now set to " << x << endl;
cout << "y is now set to " << y << endl;
}
void pass_by_value(int a)
{
a=99;
}
void pass_by_reference(int *a)
{
*a=66
I'm also getting a strange "undefined reference to WinMain@16 error when I try to run these files.
main.cpp
1 2 3 4 5 6 7 8 9 10
#include <iostream>
#include "Class.h" //Remember to add this in order to access elements from your class.
usingnamespace std;
int main()
{
Class c_one;
return 0;
}
This code here seems to work fine: http://cpp.sh/23sz http://cpp.sh/3p5c http://cpp.sh/4f6t
Your setup or how you are using Code::Blocks must be the problem. Have you tried reinstalling Code::Blocks? Also in the video I noticed that you clicked no when it asked if you wanted to build the project. You should have clicked yes. When you clicked yes there was no error. Which is expected. Try adding the line cin.get(); before return 0; in int main(). This will cause the program to wait for user input before exiting.
Why do you have 14 lines of numbers in your Class.h?
Edit: Also in the future, please do not upload code videos to youtube unless they match the resolution of your monitor. The video was really blurry. At least 720p or 1080p preferably.