Jump to content


Unknown error


3 replies to this topic

#1 NCATdesigner

    New Member

  • Members
  • Pip
  • 2 posts

Posted 05 February 2007 - 05:49 PM

Hello people!!!

I'm usig vS 2005 c++ to create a basic 3D engine, But I'm hanged just begin with somtehing I believe stupid. I'd Like to have a Log class to report all the errors but I don't know why there's an error I can't understand

Here's the error:

Error 1 error C2248: 'std::basic_ios<_Elem,_Traits>::basic_ios' : cannot access private member declared in class 'std::basic_ios<_Elem,_Traits>' D:\Archivos de programa\Microsoft Visual Studio 8\VC\include\fstream 802


Here's the code:

<Log.cpp>
#include "Log.h"

Log::Log(void)
{
	
}

Log::Log(string filename)
{
	_filename = filename;
}

Log::~Log(void)
{
}

void Log::write(string text) 
{
	 logFile.open (_filename.c_str());
	 logFile << text;
	 logFile.close();
}

void Log::writeLine(string text) 
{
	logFile.open (_filename.c_str());
  logFile << text << "\n";
  logFile.close();
}

<Log.h>
#ifndef INC_LOG_INC
#define INC_LOG_INC

#pragma once

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

class Log
{
public:
string _filename;
private:
ofstream logFile;
public:
	Log(void);
	Log(string _filename);
	~Log(void);

	void write(string text);
	void writeLine(string text);

};

#endif

I called the method with Log logFile("filename");


Another question is, If I want to send this errors to the output window of VS how can I do it?

Sorry for my bad writing And Thank you all.

#2 Cipher3D

    New Member

  • Members
  • Pip
  • 9 posts

Posted 05 February 2007 - 08:22 PM

First of all, if you do #pragma once, you do not need to do the #ifndef/#endif pairs in your header file. They're equivalent.

To answer your question, it is my hunch that it is nothing wrong with your code, but how your compiler is set up. Try compiling this code in another compiler (such as mingw -- use Dev-C++ or CodeBlocks (both free) to accomplish this). Apparently the fstream header file doesn't jive well with the compiler.

What do you mean "output window" of VS? Aren't you getting your compiler errors from the output pane?

#3 Nils Pipenbrinck

    Senior Member

  • Members
  • PipPipPipPip
  • 597 posts

Posted 05 February 2007 - 08:24 PM

for the output window you just need to:


#include <windows.h>


  // somewhere in your code:

  OutputDebugString ("Hello Debug Output Pane!\n");



#4 NCATdesigner

    New Member

  • Members
  • Pip
  • 2 posts

Posted 05 February 2007 - 09:45 PM

Thank you people

very fast!





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users