0
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <sstream>

using namespace std;

struct Uzenet
{
    string honap;
    int nap;
    string time;
    string computer_name, szolg_name, massage;
};

void kiir(const Uzenet &uzenet)
{
    cout << "Az uzenet ideje: " << Uzenet.honap << " " << Uzenet.nap << " " << Uzenet.time;
    cout << "A szamitogep neve: " << Uzenet.computer_name << " ";
    cout << "A szolgaltatas neve: " << Uzenet.szolg_name << " ";
    cout << "Az uzenet: " << Uzenet.massage << endl;
}

Uzenet beolvas(istream &input)
{
    Uzenet ret;
    string sor;
    getline(input, sor);
    stringstream ss(sor);
    ss>>ret.honap>>ret.nap>>ret.time>>ret.computer_name;
    char kuka;
    getline(ss, kuka, ':');
    ss>>kuka>>ret.massage;
    return ret;
}

vector<Uzenet> fajlbol(string fajlnev)
{
    ifstream befajl(fajlnev.c_str());
    vector<Uzenet> v;
    while (befajl.good())
    {
        Uzenet u;
        u = beolvas(befajl);
        v.push_back(u);
        return v;
    }

}

void mindentki(vector<Uzenet> v)
{
    for (unsigned int i = 0; i < v.size(); ++i)
    {
        kiir(v[i]);
    }
}


int main()
{
    Uzenet uz1, uz2, uz3;

    vector<Uzenet> v = fajlbol("logfile.txt");

    mindentki(v);


    return 0;
}

Hello!
I'm just started learning C++ and this is a homework. I get the error massage:
expected primary-expression before '-' token.

The errorr is in the "void kiir" function's all lines

2
Contributors
2
Replies
4
Views
4 Years
Discussion Span
Last Post by JasonHippy
0

The instance of the Uzenet class which you are passing into your function is called uzenet (note the capitalisation). So in the function, where you are trying to call member functions of the class, you need to use the instance name (uzenet) NOT the class name (Uzenet).

Edited by JasonHippy

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.