-3

Unexpected unqualified - id before long Unexpected unqualified - id before double Unexpected unqualified - id before const

These are the errors I am receiving on the following code.

CreditCard::long long number() const {
return cardnumber;
}

CreditCard::double balance() const {
return cardbalance;
}

CreditCard::const char* name() const {
return cardname;
}

Anyone know why this is happening?

Mykalz
  • 1
  • 1

3 Answers3

1

you need return_type ClassName::member_name(args) cv qualifier:

long long CreditCard::number() const 

etc.

juanchopanza
  • 223,364
  • 34
  • 402
  • 480
  • @KerrekSB There's free rep? I've been overpaying! – Elliott Frisch Feb 06 '14 at 21:27
  • @KerrekSB I couldn't find the duplicate. Anyway, I hit the max already, so this is rep-free answering :-) – juanchopanza Feb 06 '14 at 21:29
  • 1
    @ElliottFrisch: Sure, there's tons: Find a question about a trivial mistake, be the first [to post an answer](http://stackoverflow.com/a/21609531/596781), profit. The feeling of dying a little on the inside will stop being annoying after a while. – Kerrek SB Feb 06 '14 at 21:32
1

The return type goes before the class name,

long long CreditCard::number() const {
  return cardnumber;
}

double CreditCard::balance() const {
  return cardbalance;
}

// This should probably return a std::string
const char* CreditCard::name() const {
  return cardname;
}
Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
0

The return types need to be specified before the class name

double CreditCard::balance() const
Captain Obvlious
  • 19,754
  • 5
  • 44
  • 74
JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454