Object oreinted Programming

I'm new to object oriented Programming.Here I want to check the available amount is greater than amount that purchasing and return true or false.Can anyone show the errors and correct those implementations .Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
 //this is my class

#pragma once
class Card
{ 
private:
	int CardNo;
	char CardType[20];
	float CreditLimit;
	float AmountUsed;


public:
	Card(int pcn,char pct[],float pcl,float pau);
	double FindAvailableBalnce(double am_av);
	double Purchase(double amount);
	void Print();


	Card(void);
	~Card(void);
};

#include "StdAfx.h"
#include "Card.h"
#include<iostream>
#include<cstring>
using namespace std;


Card::Card(int pcn,char pct[],float pcl,float pau)
{
	CardNo=pcn;
	strcpy(CardType,pct);
	CreditLimit=pcl;
	AmountUsed=pau;
	AmountUsed=0;


}

	double Card::FindAvailableBalnce(double am_av)
	{
		return am_av=CreditLimit-AmountUsed;

	}

	bool Card::Purchase(double amount)
	{
		if(am_av>amount)
			
			return true;
		

	}

	void Card::Print()
	{
		cout<<"Credit Card No: "<<CardNo<<endl;
		cout<<"Credit Card Type: "<<CardType<<endl;
		cout<<"Available Amount: "<<am_av<<endl;


	}


Card::Card(void)
{
}


Card::~Card(void)
{
}
> Can anyone show the errors
A compiler may.
1
2
3
4
5
6
7
8
9
10
11
foo.cpp:48:12: error: return type of out-of-line definition of 'Card::Purchase' differs from that in the declaration
bool Card::Purchase(double amount)

foo.cpp:16:10: note: previous declaration is here
double Purchase(double amount);

foo.cpp:50:5: error: use of undeclared identifier 'am_av'
        if(am_av>amount)

foo.cpp:61:30: error: use of undeclared identifier 'am_av'
        cout<<"Available Amount: "<<am_av<<endl;
Last edited on
Topic archived. No new replies allowed.