|
-
Aug 23rd, 2000, 04:39 PM
#1
Thread Starter
Lively Member
-
Aug 23rd, 2000, 05:07 PM
#2
Lively Member
I don't spot anything unusual immediately. However without your class declaration I can't be sure. I noticed in your main that you have
#include <iostream>
using namespace std;
but in your CPlayer class you have:
#include "iostream.h"
Why?
iostream (without the .h) isn't needed unless you plan on using stl in your project. Either way you should use one or the other.
Using this main
Code:
#include <iostream>
#include "Player.h"
using namespace std;
void main()
{
CPlayer guy;
guy.jump(); // The guy suppose to JUMP here but he doesn't!!!
}
This Header:
Code:
class CPlayer{
public:
CPlayer();
~CPlayer();
void jump();
};
and This CPP:
Code:
#include "iostream.h"
#include "Player.h"
CPlayer::CPlayer()
{
}
CPlayer::~CPlayer()
{
}
void CPlayer::jump()
{
cout << "Player jumped!";
}
It works fine. I get "Player jumped!" on the screen
[Edited by CthulhuDragon on 08-24-2000 at 10:46 AM]
-
Aug 23rd, 2000, 06:57 PM
#3
Thread Starter
Lively Member
thanks
Thanks CthulhuDragon!! i fogot to include the "player.h" in my main file, so now it works like a charm! .
the reason I used <iostream> is because someone said you can use this too. it works fine both ways now so thanks again!!
-
Aug 24th, 2000, 12:47 PM
#4
Monday Morning Lunatic
I beg to differ on the iostream issue. It isn't part of the STL, but of the Standard C++ Library, which includes the IOStream library, string streams, and STL. I always use the std:: headers, since they are actually better than Microsoft's own one. (Actually, MS hint that you should use the std:: ones).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|