Hi,
First let me say thank you in advance to anybody who is willing to take the time to help me out.
I am a VB6 guy from way back trying to update my programming skills. I thought I would try C++. I'm working with Visual C++ 2008.
It's been going pretty well but I have run into a difficulty. It's probably a very simple thing for experienced programmers but C++ is great divergence from VB6 and I'm a stuck.
My goal is to output a simple log file. I thought this would work best via a source (cpp) file as opposed to rewriting it for every form. I have created the .h header file and the .cpp file but can't seem to make it work. I've rewritten it 50 times at this point and google searched and dug through my book but can't seem to figure it out.
I will throw some code out here, it's probably as scrambled as my brain at this point so please consider it a starting point.
Here is my CPPLog.cpp source file: (what do I actually need to #include and where and how do I need to innitialize the string?)
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include "stdafx.h"
#include "CPPLog.h"
#include <iostream>
#include <string>
using namespace System::IO;
using namespace System;
String ^ sLog;
void pLogWriter(String ^ sLog){
StreamWriter^ LogFile = gcnew StreamWriter("LogFile.txt");
LogFile->WriteLine(sLog);
LogFile->Close();
}
|
Here is my CPPLog.h header file: (I get an error saying invalid use of void. Plus I read on some web site you can simply use the keyword "string" in the declaration but don't know if this is correct.)
1 2 3 4 5 6
|
#ifndef CPPLOG_H
#define CPPLOG_H
void pLogWriter(string);
#endif
|
Here is my main form:
1 2 3
|
#include "CPPLog.h"
pLogWriter("Test");
|
Thanks again for your help, I greatly appreciate it.