[Linker error] undefined reference to `add()'
Can someone explain that a little? Do i need to include my code to help you guys explain? Thanks
[Linker error] undefined reference to `add()'
Can someone explain that a little? Do i need to include my code to help you guys explain? Thanks
[Linker error] undefined reference to `add()'
Can someone explain that a little? Do i need to include my code to help you guys explain? Thanks
It never hurts to include your code (provided it's not too long! O_O).
Just be sure to use code tags @_@
-Alex
#include <iostream>
#include <windows.h>
using namespace std;
float v1,v2,ans;
char oper;
char agn;
int simp(){
void add();
{
ans = v1 + v2;
}
void sub();
{
ans = v1 - v2;
}
void mult();
{
ans = v1 * v2;
}
void div();
{
ans = v1 / v2;
}
do{
system("cls");
cout<< "Value 1 >>";
cin>> v1;
cout<< "Value 2 >>";
cin>> v2;
cout<< "Operator >>";
cin>> oper;
if (oper == '+')
{
add();
cout<<endl;
cout<<'\t'<<ans<<endl<<endl;
cout<< "Do you want to do another operation?"<<endl;
cout<< "y/n:";
cin>>agn;
Sleep(2000);
}
if (oper == '-')
{
sub();
cout<<endl;
cout<<'\t'<<ans<<endl<<endl;
cout<< "Do you want to do another operation?"<<endl;
cout<< "y/n:";
cin>>agn;
Sleep(2000);
}
if (oper == '*')
{
mult();
cout<<endl;
cout<<'\t'<<ans<<endl<<endl;
cout<< "Do you want to do another operation?"<<endl;
cout<< "y/n:";
cin>>agn;
Sleep(2000);
}
if (oper == '/')
{
div();
cout<<endl;
cout<<'\t'<<ans<<endl<<endl;
cout<< "Do you want to do another operation?"<<endl;
cout<< "y/n:";
cin>>agn;
Sleep(2000);
}
}
while (agn == 'y');
cout<<"Good Bye";
Sleep(1000);
}
int main()
{
char choice;
SetConsoleTitle("Simple-Calc V.1");
cout<<"1. Simple Operations(+-*/) 2-Intergers"<<endl;
cout<<"2. Average (3 Numbers)"<<endl;
cin>>choice;
if (choice == '1')
{
simp();
}
return(0);
}
There ya go, im working on a calculator program =D
You can't declare a method within another method O_O
You'll have to pull all of your other methods (add, subtract etc) outside of the definition of your simp method. Your simp method can have the logic of the continuous play, but it can't have method definitions >_<
-Alex
well that was easy! lol, thanks a lot alex.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.