dealing with struct

Hello guys,

I have the following code for .h e .cpp of a class.

In the .h I declare a struct "metaTable" in which I need to use in the .cpp, but for somehow I can`t use it just by calling it`s name. I also have to declare it on file .cpp. The problem is, I can`t create a vector of "metaTable" in .cpp because it returns me the error 'metaTable was not declared in this scope'.

Anyone knows how to solve this?

FileStream.h

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
#include <string>

#ifndef FILESTREAM_H
#define	FILESTREAM_H

class FileStream {
public:
    FileStream();
    FileStream(const FileStream& orig);
    virtual ~FileStream();
    
    struct metaTable {
    int numberOfFields;
    std::string tableFileName;
    std::string tableName;
    std::string fieldName[4];
};

    void loadDatabase(std::string databaseMetadata);
    void loadTables(metaTable metadata);

private:

};

#endif	/* FILESTREAM_H */ 


and

FileStream.cpp

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
#include "FileStream.h"
#include <cstdlib>
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <vector>

FileStream::FileStream() {
}

FileStream::FileStream(const FileStream& orig) {
}

FileStream::~FileStream() {
}

struct metaTable {
    int numberOfFields;
    std::string tableFileName;
    std::string tableName;
    std::string fieldName[4];
};

std::vector<metaTable> metaTableList;

struct table {
    std::string field1[10];
    std::string field2[10];
    std::string field3[10];
    std::string field4[10];
};

std::vector<table> tableList;
closed account (o1vk4iN6)
vector<FileStream::metaTable> metaTableList;

Since it's defined in FileStream you need to use it like a namespace when defining it outside of the class.
Worked, thanks!
Topic archived. No new replies allowed.