Undefined Reference
question: What error are they getting?, context: Getting"Undefined Reference Error",not sure why! Here's the code of my program: #include&lt;iostream&gt; using namespace std; class Marks { private: static int x,y,s,a; public: static int sum() { cout&lt;&lt;"Enter marks of 1st subject: "; cin&gt;&gt;x; cout&lt;&lt;endl&lt;&lt;"Enter marks of 2nd subject: "; cin&gt;&gt;y; s=x+y; return s; } static float average() { cout&lt;&lt;"Enter marks of 1st subject: "; cin&gt;&gt;x; cout&lt;&lt;endl&lt;&lt;"Enter marks of 2nd subject: "; cin&gt;&gt;y; a=(x+y)/3; return a; } }; int main() { cout&lt;&lt;endl&lt;&lt;"Sum is: "&lt;&lt;Marks::sum(); cout&lt;&lt;endl&lt;&lt;"Average is: "&lt;&lt;Marks::average(); } It's a simple program where I have to initialize static members through user input. The user input will be taken in a static member function. I am getting the undefined reference error. Any kind of help will be appreciated. Thank you!
What error are they getting?
Getting" Undefined Reference Error",not sure why!
Getting"Undefined Reference Error",not sure why! Here's the code of my program: #include&lt;iostream&gt; using namespace std; class Marks { private: static int x,y,s,a; public: static int sum() { cout&lt;&lt;"Enter marks of 1st subject: "; cin&gt;&gt;x; cout&lt;&lt;endl&lt;&lt;"Enter marks of 2nd subject: "; cin&gt;&gt;y; s=x+y; return s; } static float average() { cout&lt;&lt;"Enter marks of 1st subject: "; cin&gt;&gt;x; cout&lt;&lt;endl&lt;&lt;"Enter marks of 2nd subject: "; cin&gt;&gt;y; a=(x+y)/3; return a; } }; int main() { cout&lt;&lt;endl&lt;&lt;"Sum is: "&lt;&lt;Marks::sum(); cout&lt;&lt;endl&lt;&lt;"Average is: "&lt;&lt;Marks::average(); } It's a simple program where I have to initialize static members through user input. The user input will be taken in a static member function. I am getting the undefined reference error. Any kind of help will be appreciated. Thank you!
Getting" <hl> Undefined Reference <hl> Error",not sure why!
Getting"<hl> Undefined Reference <hl> Error",not sure why! Here's the code of my program: #include&lt;iostream&gt; using namespace std; class Marks { private: static int x,y,s,a; public: static int sum() { cout&lt;&lt;"Enter marks of 1st subject: "; cin&gt;&gt;x; cout&lt;&lt;endl&lt;&lt;"Enter marks of 2nd subject: "; cin&gt;&gt;y; s=x+y; return s; } static float average() { cout&lt;&lt;"Enter marks of 1st subject: "; cin&gt;&gt;x; cout&lt;&lt;endl&lt;&lt;"Enter marks of 2nd subject: "; cin&gt;&gt;y; a=(x+y)/3; return a; } }; int main() { cout&lt;&lt;endl&lt;&lt;"Sum is: "&lt;&lt;Marks::sum(); cout&lt;&lt;endl&lt;&lt;"Average is: "&lt;&lt;Marks::average(); } It's a simple program where I have to initialize static members through user input. The user input will be taken in a static member function. I am getting the undefined reference error. Any kind of help will be appreciated. Thank you!
<hl> Getting" Undefined Reference Error",not sure why! <hl> Here's the code of my program: #include&lt;iostream&gt; using namespace std; class Marks { private: static int x,y,s,a; public: static int sum() { cout&lt;&lt;"Enter marks of 1st subject: "; cin&gt;&gt;x; cout&lt;&lt;endl&lt;&lt;"Enter marks of 2nd subject: "; cin&gt;&gt;y; s=x+y; return s; } static float average() { cout&lt;&lt;"Enter marks of 1st subject: "; cin&gt;&gt;x; cout&lt;&lt;endl&lt;&lt;"Enter marks of 2nd subject: "; cin&gt;&gt;y; a=(x+y)/3; return a; } }; int main() { cout&lt;&lt;endl&lt;&lt;"Sum is: "&lt;&lt;Marks::sum(); cout&lt;&lt;endl&lt;&lt;"Average is: "&lt;&lt;Marks::average(); } It's a simple program where I have to initialize static members through user input. The user input will be taken in a static member function. I am getting the undefined reference error. Any kind of help will be appreciated. Thank you!