Need help with this. Any suggestions?


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
#include <iostream>
#include <string>
using namespace std;

class Telknyga
{
public:
    virtual ~Telknyga();
    virtual void Show() = 0;
};
class Tasmuo : public Telknyga
{
protected:
    string Vardas;
public:
    Tasmuo()
    {
        Vardas.clear();
    };
    virtual ~Tasmuo();

// void Input();
    virtual void Show();
};
class Input : public Tasmuo
{
protected:
    Input *Array = NULL;
    int max = 2;
public:
    Input();
    virtual ~Input();

    void Enter()
    {
        Array = new Input[max];
        for(int i = 0; i < max; i++)
        {
            cout << "Iveskite Varda : ";
            cin >> Array[i].Vardas;
            cout << endl;
        }
    }
    void Show()
    {
        for(int i = 0; i < max; i++)
        {
            cout << "Vardas : " << Array[i].Vardas << endl;
        }
    }
};
class Sort : public Input, public Tasmuo
{
protected:
public:

    Sort();
    virtual ~Sort();
//Will be sort function
    virtual void Show()
    {
        for(int i = 0; i < max; i++)
        {
            cout << "Vardas : " << Array[i].Vardas << endl; /// Here is a problem
            
            // If i just do like so it's also a problem
            // cout << "Vardas : " << Tasmuo::Vardas << endl;

        }
    }

};
int main()
{
    Tasmuo **c = new Tasmuo *[2] ;
    Input A;
    Sort B;
    c[0] = &A;
    A.Enter();
    A.Show();
    cout << "############" << endl;
    c[0]->Show();
    cout << "#############" << endl;
    B.Show(); //Here is problem
    return 0;
}
http://www.cplusplus.com/forum/articles/40071/#msg218019

http://cplusplus.com/doc/tutorial/classes/
An object is an instantiation of a class. In terms of variables, a class would be the type, and an object would be the variable.
Topic archived. No new replies allowed.