'vector name' does not name a type?????

Hi, I've this problem. The builder say me "'dati' does not name a type". Why? Ok, it doesn't name a type, but I don't want 'dati' as a type name. dati is variable and its type is a vector. If i do this thing in the main() the compiler build it and the program work perfectly. What's the problem?



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <cmath>
#define  M_PI           3.14159265358979323846
#include <cctype>
#include <sstream>
#include <stdlib.h>
#include <conio.h>
using namespace std;


int C,N,i=0;

class campione {
public:

    vector<vector<long double>> dati;
    dati.resize(C);

    void input() {
        string temp,nome;
        cin >> nome;

        ifstream file1(nome);

        while(getline(file1,temp)){
            istringstream is(temp); 
            vector<long double> TEMP(C,0); 
            for(int I=0; I<C; ++I) {
                is >> TEMP.at(I);
                dati.at(I).push_back(TEMP.at(I));
            }
        }
    } 

};
Last edited on
You can't write statements like dati.resize(C); outside of a function. If you want to resize the vector when the campione object is created you should put it in the constructor.
thank you, now it works
Topic archived. No new replies allowed.