向工程中添加1.h和1.cpp,为什么提示找不到??

xiayule 2003-10-09 11:13:54
1、向工程中添加1.h和1.cpp,然后再主程序中#include "1.h",为什么提示
cant open 1.h file?而我把1.h和1.cpp复制到application目录下,就可以,
除了复制还有什么方法?
2、#include "StdAfx.h"
#include "TStack01.h"
#include "iostream.h"
void main(void)
{
stack<float> floatstack(5);
float f=1.01;
cout<<"pushing elements onto floatstack\n";

while (floatstack.push(f)) {
cout<<f<<'\n';
f+=1;
}
// return 0;
}最后有错误:fatal error C1075: end of file found before the left brace '{' at 'g:\程序\c++\c++ design tutorial\3.10\stack\tstack01.h(6)' was matched,不明白什么意思?〉
...全文
68 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
williamVII 2003-10-10
  • 打赏
  • 举报
回复
出错信息在第六行,表示类的定义出了问题.

isEmpty那一行最后的小括号应该改为大括号...
楼主大概是不小心打错了...



xiayule 2003-10-10
  • 打赏
  • 举报
回复
to williamVII(spread):
新建文件时,Add to project,已经勾上。
你怎么知道第六行有问题:
//tstack01.h
#ifndef TStack01_h
#define TStack01_h
template <class T>

class stack:public
{
public:
stack(int=10);
~stack(){delete [] stackptr};
int push(const T &);
int pop(T &);//popout a element from the stack
int isEmpty(){return top==-1);//return 1,if the stack if empty
int isFull(){return top==SIZE-1};//return 1,if the stack if full
private:
int size;
int top;
T * stackptr;//the pointer to stack
};
template<class T>
stack<T>::stack(int s){
size=s;
top=-1;
stackptr=new T(size);
}
template<class T>
stack<T>::push(const T&item){
if (!isFull()){
stackptr(++top)=item;
return 1;//access successfully
}
return 0;
}
template<class T>
stack<T>::pop(T&popValue){
if (!isEmpty()){
popValue=stackptr(--top);
return 1;
}
return 0;
}
#endif
xiayule 2003-10-09
  • 打赏
  • 举报
回复
to daizh:
project->settings->c/c++添加路径,找不到阿,有一个category,warning level,optimization,debug info,preprocessor definitions,project options
哪一个?
xiayule 2003-10-09
  • 打赏
  • 举报
回复
、#include "StdAfx.h"
#include "TStack01.h"
#include "iostream.h"
void main(void)
{
stack<float> floatstack(5);
float f=1.01;
cout<<"pushing elements onto floatstack\n";

while (floatstack.push(f)) {
cout<<f<<'\n';
f+=1;
}
// return 0;
}最后有错误:fatal error C1075: end of file found before the left brace '{' at 'g:\程序\c++\c++ design tutorial\3.10\stack\tstack01.h(6)' was matched,不明白什么意思?〉
daizh 2003-10-09
  • 打赏
  • 举报
回复
在project->settings->c/c++添加路径
leyt 2003-10-09
  • 打赏
  • 举报
回复
aditional include directory
williamVII 2003-10-09
  • 打赏
  • 举报
回复
1.新建文件时,Add to project,楼主有没有勾上?

2.头文件第六行有问题.tstack01.h(6)

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧