2011-12-24 66 views
0

我正在試圖從一本書的示例代碼中獲得幫助,因此我不完全確定我到目前爲止在頭文件中可能有哪些錯誤。錯誤C2504:'ios':base class undefined

我不斷收到以下錯誤消息。

錯誤2錯誤C2061:語法錯誤:識別符 '流緩衝'
錯誤1個錯誤C2504: 'IOS':基類未定義
錯誤5智能感知:標識符 「流緩衝」 是未定義

// StdAfx.h HEADER FILE 
************************** 
// stdafx.h : include file for standard system include files, 
// or project specific include files that are used frequently, but 
// are changed infrequently 
// 

#pragma once 
#include <iostream> 
#include <strstream> 
#include <iomanip> 
#include <ios> 
#include <stdio.h> 
#include <tchar.h> 
#include "targetver.h" 


// Conios HEADER FILE 
************************** 

#include "Stdafx.h" 



class Conios :virtual public ios{ 
protected: 
public: 

    Conios(void); 
    ~Conios(void); 
    Conios(streambuf* Buffer); 
}; 

回答

5

ios位於std-名稱空間中。所以要麼使用use namespace std;,要麼從std::ios擴展而不是ios

如果您正在使用use namespace只在您的實現,文件,如*.cpp*.cxx使用它,做use namespace ...頭文件 - 永遠!

streambuf也是如此。

+0

工作正常!謝謝。 – Kobojunkie 2011-12-24 06:50:34

+1

建議他使用'use namespace std;'是非常糟糕的建議。更好的建議是告訴他不要**使用它。 – Nawaz 2011-12-24 07:05:00

+1

@Nawaz:你說得對,我在我的回答中加入了(但是在實現文件中使用'namespace'被接受,不是嗎?)。 – vstm 2011-12-24 07:32:21