hii to all i am very new to c++ . i am learning c++ while i try to compile this program it give error as "pair as ambiguous symbol" error.

in this program iam trying to understand the how polymorphism works.

#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include "mouse.hpp"
using namespace std;

class pair
{
public:
    pair(int xx=0, int yy=0);
    int x() const;
    int y() const;

private:
    int x_value, y_value ;
};
class shape
{
public:
    virtual void rotate(double);
    virtual double get_area() const;

pair get_position() const;
protected:
pair centre;
};
class circle : public shape
{
public:
    void rotate(double) const
    {
    }
    double get_area() const
    {
        return pi*rad*rad;
        }
protected:
    static const double pi;
    double rad;
};
class rectangle : public shape
{
public:
    double get_area() const
    {
        return size.x()+size.y();
    }
protected:
    pair size;
};
int _tmain(int argc, _TCHAR* argv[])
{


    circle c;
    rectangle r;
    shape *ps=&c;
    cout<< ps->get_area();
getch();
return 0;
}

This is a case where using using namespace std; is destroying your program. The compiler doesn't know whether to use the pair class you wrote or the one in std namespace <utility> header file. Replace that with using std::cout; and that error will go away.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.