Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

Wyświetlanie elementu vectora error C2679: binary

Ostatnio zmodyfikowano 2015-06-02 21:28
Autor Wiadomość
erloon
Temat założony przez niniejszego użytkownika
Wyświetlanie elementu vectora error C2679: binary
» 2015-06-02 21:11:52
Cześć,
Próbuję wyświetlić zawartość vectora, który przechowuje obiekty stworzonej klasy Trójkat
Próbuję znaleźć jakieś rozwiązanie i nic. Moze ktoś będzie wiedział gdzie popełniam błąd.

Fragment gdzie jest błąd
C/C++
for( int i = 0; i < lista.size(); i++ )
{
    cout << lista[ i ];
}
return 0;

Cały kod:

C/C++
#include "stdafx.h"
#include <iostream>
#include <istream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <conio.h>
#include <ostream>
using namespace std;


struct punkt
{
    int x, y;
};

class Trojkat
{
public:
    Trojkat( int * p1x, int * p1y, int * p2x, int * p2y, int * p3x, int * p3y );
    bool sprawdzT( punkt & p1, punkt & p2, punkt & p3 )
    {
        //dlugosc bokow
        double d1, d2, d3;
        d1 = pow(( pow(( p1.x - p2.y ), 2 ) + pow(( p1.y - p2.y ), 2 ) ), 1.0 / 2 );
        d2 = pow(( pow(( p2.x - p3.y ), 2 ) + pow(( p2.y - p3.y ), 2 ) ), 1.0 / 2 );
        d3 = pow(( pow(( p3.x - p1.y ), 2 ) + pow(( p3.y - p1.y ), 2 ) ), 1.0 / 2 );
        //czy to trojkat
        if( d1 + d2 > d3 && d1 + d3 > d2 && d2 + d3 > d1 ) { return 1; }
        else { return 0; };
        //wybranie najdluzszego
        /*vector<double> figura;
        figura.push_back(d1);
        figura.push_back(d2);
        figura.push_back(d3);
        sort(figura.begin(), figura.end());
        double *p = figura.data();
        */
       
    };
    void wyswietlT()
    {
        cout << "P1= (" << p1.x << "," << p1.y << ") P2= (" << p2.x << "," << p2.y << ") P3= (" << p3.x << "," << p3.y << ")" << endl;
    }
    ~Trojkat();
   
private:
    punkt p1, p2, p3;
};

Trojkat::Trojkat( int * p1x, int * p1y, int * p2x, int * p2y, int * p3x, int * p3y )
{
    this->p1.x = * p1x;
    this->p1.y = * p1y;
    this->p2.x = * p2x;
    this->p2.y = * p2y;
    this->p3.x = * p3x;
    this->p3.y = * p3y;
};

Trojkat::~Trojkat()
{
    cout << "zadzialal destruktor" << endl;
};


int main()
{
    cout << "Wprowadz dane trojkata" << endl;
    char wyb;
    vector < Trojkat > lista;
    do
    {
        int a, b, c, d, e, f;
        cout << "Wprowadz wspolrzedne 3 punktow" << endl;
        cout << "P1.X "; cin >> a;
        cout << "P1.Y "; cin >> b;
        cout << "P2.X "; cin >> c;
        cout << "P2.Y "; cin >> d;
        cout << "P3.X "; cin >> e;
        cout << "P3.Y "; cin >> f;
        Trojkat zm( & a, & b, & c, & d, & e, & f );
        lista.push_back( zm );
        cout << "Dodac kolejny? Y/N"; cin >> wyb;
    } while( wyb = 'N' );
   
    for( int i = 0; i < lista.size(); i++ )
    {
        cout << lista[ i ];
    }
    return 0;
}
P-133105
Monika90
» 2015-06-02 21:15:58
C/C++
lista[ i ].wyswietlT();

albo zdefiniuj operator <<
P-133106
erloon
Temat założony przez niniejszego użytkownika
» 2015-06-02 21:28:57
Dziękuję, pomogło. ;-)
P-133108
« 1 »
  Strona 1 z 1