我在 main.cpp 的另一个 .h 和 .cpp 文件中有一个类。
在 main.cpp 中:
#include <iostream>
#include "filestuff.h"
#include "stream.h" <-- right here
int main(int argc, char** args)
{
if(!args[1])
return 0;
u64 filesize = 0;
get_file_size(args[1], &filesize);
u8* fd = new u8[filesize];
read_file(args[1], fd, filesize);
Stream s = new Stream(fd, filesize, "rb", BigEndian );
getchar();
return 0;
}
在 Stream.h
#include <iostream> //just in case?
#if defined(_WIN32) && defined(_MSC_VER)
typedef __int64 s64;
typedef unsigned __int64 u64;
#else
typedef long long int s64;
typedef unsigned long long int u64;
#endif
typedef unsigned long int u32;
typedef signed long int s32;
typedef unsigned short int u16;
typedef signed short int s16;
typedef unsigned char u8;
typedef signed char s8;
#define LittleEndian 0x1
#define BigEndian 0x2
class Stream
{
public:
Stream(u8* buffer, u64 length, char* access, int IOType);
private:
u8* buffer;
u64 pos;
u64 len;
};
在 Stream.cpp 中
#include "stream.h"
Stream::Stream(u8* buffer, u64 length, char* access, int IOType)
{
u8* buf = new u8[length];
buffer = buf;
}
我如何使用下面的代码来初始化我的类,就像我现在想做的那样main
?
Stream* s = new Stream(fd, filesize, "rb", BigEndian );