class problem

I have written this program ..Although compiler is telling the problem but i could not identify what problem is present.


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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include<iostream>
#include<string>
using namespace std;
/////////////////////////////
class publication
{
	protected :
			float price;
			string title; 
		
		
	public :
		
		publication(float p , string t)
		{
			price = p;
			title = t;
			
			
		}
		
		
		void getdata()
		{
			cout << "Enter Price:" ;
			cin >> price;
			
			cout << "Enter title:";
			getline(cin,title);
				
		}
		
		void putdata()
		{
			cout << "Price is \n"<< price;
			cout <<"tile is \n" << title;
		}
};

/////////////////////////
class book : public publication 
{
	protected :
			int pcount;
	
	public :
		
		void getdata() 
		{
			cout <<"Enter page count";
			cin >> pcount;  
			
		}
		
		void putdata()
		{
			cout << "page count is \n " << pcount;
		}
	
	book(float price , string title , int pc) : publication(price,title)
	{
		pcount = pc;
		
		
	}
	
	
};
/////////////////////
class tape : public publication 
{
	
	
	protected :
			int play_time;
	
	public :
	void getdata()
		{
			cout << "enter play time" ;
			cin >> play_time;
			
		}
		
		void putdata()
		{
			cout << "The play time is "<< play_time;
			
		}	
	tape(float price , string title , int pt) : publication (price,title)
	{
		play_time = pt;
		
		
	}
	
	
};


///////////////////////






int main()
{
	book b;
	tape t;
	
	cout << "Book \n";
	b.publication ::getdata();
	b.book ::getdata();
	
	
	cout << "Tape\n";
	t.publication :: getdata();
	t.tape ::getdata();
	
	
	cout <<"Data is as Follows \n";
	b.publication::putdata();
	b.book :: putdata();
	t.publication :: putdata();
	t.tape :: putdata();
	 
	
	
	cin.get();
	return 0;	
}  

One problem is that you created custom constructor for class
book::book(float price , string title , int pc), but in main(), line 110 you are calling nonexistent book::book();
Since you provided custom constructor, no default is autogenerated, so you must provide it yourself. The same is the case for tape.
Last edited on
Topic archived. No new replies allowed.