#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

Recommended Answers

All 2 Replies

Error is in line 19, 19, 19, 20, 21, 22

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).

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.