delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/09/22/18:01:24

From: "Gordon Bergström" <gordon DOT bergstrom AT swipnet DOT se>
Newsgroups: comp.os.msdos.djgpp
Subject: Strange behavior?
Lines: 68
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Message-ID: <T3aG3.279$Mj5.391@nntpserver.swip.net>
NNTP-Posting-Host: 212.151.59.14
X-Complaints-To: news-abuse AT swip DOT net
X-Trace: nntpserver.swip.net 938028403 212.151.59.14 (Wed, 22 Sep 1999 21:26:43 MET DST)
NNTP-Posting-Date: Wed, 22 Sep 1999 21:26:43 MET DST
Organization: A Customer of Tele2
X-Sender: s-351759 AT d212-151-59-14 DOT swipnet DOT se
Date: Wed, 22 Sep 1999 21:25:55 +0200
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Dear group.

I'm having bigtime trouble with DJGPP.

It tells me:

game.cpp:5: semicolon missing after declaration of `class Player'
player.cpp:3: semicolon missing after declaration of `Player'
player.cpp:4: extraneous `char' ignored
player.cpp:4: new declaration `class Player * Player::GetPlayerName() const'
player.h:11: ambiguates old declaration `char * Player::GetPlayerName()
const'

I have this code:

<----------CODE STARTS HERE------------>
<----Main prog---->
#include <iostream>
#include "player.h"

main()
{
   Player myPlayer;
   cout << "Player:\t" << myPlayer.GetPlayerName() << endl;
   cout << "Score:\t" << myPlayer.GetPlayerScore() << endl;
   cout << "Position:\t" << myPlayer.GetPlayerPosition() << endl;

   return 0;
}
<----------------->
#ifndef _Player_
#define _Player_
class Player
{
   private:
       char name[25];
       int score;
       int position[4];

   public:
       char* GetPlayerName() const;
       int GetPlayerScore() const;
       int* GetPlayerPosition() const;
}
#endif
<------------>
#include "player.h"

char* Player::GetPlayerName() const
{
    return &namn;
}

int Player::GetPlayerScore() const
{
     return score;
}

int* Player::GetPlayerPosition() const
{
     return &position;
}
<--------------------CODE END---------------->

Regards
Gordon


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019