I have got problems with printing of my code . I want to print a stack in which i have stored nothing and the size of stack is 5 elements from 0-4 . In the code I am using aggregation and hae defined 2 (.h) files CComplex and ClifoBuffer

#include <iostream>              
#include <stdlib.h>

#ifndef CLIFOBUFFER_H
#define CLIFOBUFFER_H
#include "CComplex.h"

class ClifoBuffer
{
public:

    ClifoBuffer(int size);
    ~ClifoBuffer();
     void print();
     bool push(const CComplex& data);
private:
    int m_size;


    CComplex* m_pBuffer;
    int m_tos;
};


In ClifoBuffer function print is invoked 

void ClifoBuffer::print()
{
    cout<<"CLifoBuffer at  "<<this<<endl;
    cout<<"m_tos=  "<<m_tos<<endl;

    for(int i=0;i<m_size;i++)
    {
        cout<<i<<".      "<<m_pBuffer[i]<<endl;

    }
}

whenever i build the solution I get the following error

binary '<<' : no operator found which takes a right-hand operand of type 'CComplex' (or there is no acceptable conversion)

kindly help

cout<<i<<". "<<m_pBuffer[i]<<endl;//m_pBuffer[i] is a CComplex

CComplex is a class and you can't print it in this case. Maybe you could try printing a value contained in that class.

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.