Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MPG

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

This topic is 5420 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
your code is so fucked up. you really need to read something about c++ before starting to code.

Share this post


Link to post
Share on other sites
I know how to code, but every time I edit and compile it spits out junk and says I am missing semi-colons...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
...as well as change something on every single line of your code

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

"I''m a half time coder, full time Britney Spears addict"
Targhan

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!