stupid error;is vc++ haunted?..?

Started by
16 comments, last by MPG 20 years, 3 months ago
heres the code:
#include <iostream>
#include <conio.h>

int main(){
int x;
int y;
void add();
{
	;std::cout<<"x+y";std::endl
		;}


;std::cout<<"welcome to calc +!!";std::endl
;std::cin>>x,y;
add()

;getch();

	return 0;

	;}
 
error: c:\Documents and Settings\Randle\My Documents\Visual Studio Projects\done\over.cpp(10): error C2568: ''identifier'' : unable to resolve function overload line 10 ___________________________ p.s i know some people think i can man an MMORPG with a blind fold on and a headach... but can someone help
Advertisement
dont use std
use something like scanf or getc
bug is the comma:
std::cin>>x,y; -> std::cin>>x; std::cin>>y;

also the semicolon after declaration of add()

quote:
Dick's Lemma:
"Just because you`re paranoid doesn`t mean they`re not out to get you."

The Programmer's dilemma:
"Programming is like sex: One mistake and you're providing
support for a lifetime."


[edited by - caesar4 on January 17, 2004 12:33:16 PM]
Cartman's definition of sexual harrasement:"When you are trying to have intercourse with a lady friend, and some other guy comes up and tickles your balls from behind"(watch South Park, it rocks)
is my function right,because thats where the error is
your code is so fucked up. you really need to read something about c++ before starting to code.
I know how to code, but every time I edit and compile it spits out junk and says I am missing semi-colons...
C++ does not support local function definitions. You need to move your add() function out of the scope of main to namespace scope, and alter it so that it takes parameters.
...as well as change something on every single line of your code

--------------------------------

"I''m a half time coder, full time Britney Spears addict"
Targhan
--------------------------------"I'm a half time coder, full time Britney Spears addict" Targhan
are you syaing make the funtion first then iint maiin{ or

{
add()
}
quote:Original post by MPG
are you syaing make the funtion first then iint maiin{ or

{
add()
}


Add ofcourse...

Do it like this instead ffs:

#include <iostream>

void add(int x, int y)
{
std::cout << x+y << std::endl;
}


int main()
{
int x;
int y;


std::cout << "Welcome to calc+!" << std::endl;
std::cin >> x,y;
add(x, y);

int mu;cin>>mu;
return 0;
}
You have to put semi-colons after your statements. Most of that should work, but doing it that way is very error-prone. Do this:
int main(){    cout<<"Hi!\n";    cout<<"Welcome to calc\n";    return 0;}  

not this:
int main(){   // note the semi-colon before cout<<"Hi!\n" is not necesarry   // as there is no statement before that   ;cout<<"Hi!\n"   ;cout<<"Welcome to calc\n"   ;return 0;}  

And why are you declaring a function in int main!? You don't put semi-colons after you declare a function. std::cout<<"x+y" will output the string "x+y", not the value of x+y. std::endl can't be put on it's own line (like any other c++ class or struct or variable for that matter). You should output endl. eg:
std::cout<<x+y<<std::endl;

edit:
Also, reread (or just read) a C++ book. I don't know where you picked up that coding style, but it's horrendous. Most of it's not even valid C++.

[edited by - brassfish89 on January 17, 2004 1:21:04 PM]

This topic is closed to new replies.

Advertisement