0

I've got the problem with following code. It should get the object parameters from the txt file. Of course to get enum values correctly I've made this simple getline() function. I'm keep getting errors which I've tried to repair, but I still have no idea what's wrong. VC says that 'no instance of overloaded function getline matches the argument list'.

My code:

CKomputer.cpp

#include <iostream>
#include <cstdio>
#include <string>
#include <fstream>


#include "CKomputer.h"
#include "Procesor.h"
#include "KartaDzwiekowa.h"

#define TESTPR1

using namespace std;

void Komputer::pobierz(string nazwa)
{
    #ifdef TESTPR1
    cout<<"Uruchomiono metode pobrania stanu obiektu Komputer z pliku"<<endl;
    #endif
    ifstream plik_wejsciowy;
    plik_wejsciowy.open(nazwa+".txt");

    int zastos;
    getline(plik_wejsciowy,linia);
    zastos=atoi(linia.c_str());
    zastosowanie=Komputer::zastosowanie(zastos);

    plik_wejsciowy >> nazwa_komputera >> ram >> ile_kart_dzwiekowych >> zastos;

    procesor.wczytaj(plik_wejsciowy);
    if (ile_kart_dzwiekowych>0)
    {
        for (int i=0;i<ile_kart_dzwiekowych;i++)
            karta_dzwiekowa[i].wczytaj(plik_wejsciowy);
    }

    plik_wejsciowy.close();
}

CKomputer.h

#pragma once

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

#include "UrzadzenieElektroniczne.h"
#include "Procesor.h"
#include "KartaDzwiekowa.h"

using namespace std;

enum zastosowanie{biznes, gaming, grafika, programowanie};

class Komputer: public UrzadzenieElektroniczne
{
private:
    Procesor procesor;
    KartaDzwiekowa *karta_dzwiekowa;

protected:
    string nazwa_komputera;
    int ram;
    int ile_kart_dzwiekowych;

public:
    Komputer();
    Komputer(string nazwa_komputera2, int ram2, int ile_kart_dzwiekowych2);
    Komputer(const Komputer& k);
    Komputer(int ilosc_kart);
    ~Komputer();
    static int ile_Komputerow;
    static int licz_ile_Komputerow();
    void komp_info();
    void wlaczenieurz();
    void zapisz(string nazwa);
    void pobierz(string nazwa);

    zastosowanie zastos;
};
Jonas
  • 6,915
  • 8
  • 35
  • 53
fragon
  • 3,391
  • 10
  • 39
  • 76
  • Can you supply the prototype for getline? Hard to tell what the type mismatch may be otherwise. – Scott Jones Apr 27 '13 at 23:53
  • The problem is I didnt overload getline(), so I dont know why VC writes such message. – fragon Apr 27 '13 at 23:58
  • 1
    `getline(plik_wejsciowy,linia);` Where is linia declared? – Retired Ninja Apr 28 '13 at 00:02
  • I wondered that too - assumed it was a std::string, based on the c_str() method – Scott Jones Apr 28 '13 at 00:05
  • @6franek - in your question, you state "I've made this simple getline() function" - so are you in fact just using the std C++ getline()? – Scott Jones Apr 28 '13 at 00:08
  • Yes. I do use std getline(). – fragon Apr 28 '13 at 11:03
  • Wow, just on a side note: I find it difficult to read when variable- and functions names are not in english. And I'm not even a native speaker. I cannot remember the names, so when I see something like `karta_dzwiekowa[i].wczytaj(plik_wejsciowy);`, I've already forgotten what `karta_dzwiekowa`, `wczytaj` and `plik_wejsciowy` are... – JHBonarius Feb 23 '17 at 11:42

0 Answers0