resolve this please (beginner)

hello,
i'm a beginner and i ve started learning c++, i wanted help with this (i can't get return calc into the main function)

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;

string asd1(string x1){
cout << x1;
}

int asd2(int x2){
int calc;
calc = x2 + 2;
return calc;
}


int main (){
string x1;
int x2;
int asd2;
cout << "what's your name?" << endl;
cin >> x1;
cout << "number? (+2)" << endl;
cin >> x2;
cout << "your name is " << x1 << ", number " << asd2 << endl;

system("pause");
return 0;
}


i also tried this:

#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
using namespace std;

string asd1(string x1){
cout << x1;
}

/*int asd2(int x2){
int calc;
calc = x2 + 2;
return calc;
}*/


int main (){
string x1;
int x2;
int asd2 = x2+2;
cout << "what's your name?" << endl;
cin >> x1;
cout << "number? (+2)" << endl;
cin >> x2;
cout << "your name is " << x1 << ", number " << asd2 << endl;

system("pause");
return 0;
}

thanks in advance

thanks in advance
Try including the proper header.
 
#include <string> 


PLEASE USE CODE TAGS (the <> formatting button) when posting code.
Dear Friend
plz use calc.h header file.
look this line you wrote
cout << "your name is " << x1 << ", number " << asd2 << endl;

the correction is cout << "your name is " << x1 << ", number " << asd2(veriable) << endl;
@shivaji - And what do you suggest the OP place in his "calc.h" file? He has no declarations to place there.
Last edited on
Topic archived. No new replies allowed.