Hi,

First let me say think 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. Rather than tackle vb.net I thought I would try C++. I'm working with Visual C++ 2008.

It's been going pretty well for being only a few days into it 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 but I know it's messed up and incomplete 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?)

Code:
#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. I read on some web site you can simply use the keyword string in the declaration but don't know if this is correct.)

Code:
#ifndef CPPLOG_H
#define CPPLOG_H
 
void pLogWriter(string);
 
#endif

Here is my main form:

Code:
#include "CPPLog.h"
 
pLogWriter("Test");
Thanks again for your help, I greatly appreciate it.