Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3029

Novice: converting C++ code to CLI Form application

$
0
0
Starting out with Visual C++, so questions may seem rather trivial.

As a starter project I want convert a Neural net app from "AI Techniques for Game Programming (2002 Buckland)" to a Visual C++ CLI Forms application. I have created the interface and now I have to rewrite the in/output routines, amongst other things.

First question I have has to do with variable initialization used by Buckland. Code looks like this:

Excerpt from header file (CNeuralNet.h):

//-------------------------------------------------------------------
// define neuron struct
//-------------------------------------------------------------------
struct SNeuron
{
//the number of inputs into the neuron
int m_NumInputs;

//the weights for each input
vector<double> m_vecWeight;


//ctor
SNeuron(int NumInputs);
};

Excerpt from .cpp file (CNeuralNet.cpp):

//*************************** methods for Neuron **********************
//
//---------------------------------------------------------------------
SNeuron::SNeuron(int NumInputs): m_NumInputs(NumInputs+1)

{
//we need an additional weight for the bias hence the +1
for (int i=0; i<NumInputs+1; ++i)
{
//set up the weights with an initial random value
m_vecWeight.push_back(());
}
}

Question I have: what is the the function of ": m_NumInputs(NumInputs+1)" after the method declaration? Buckland does this in many places in his code. In this case it's a struct, but he does it with classes too.

This is not used in the Visual C++ books I use for learning and besides that, I wonder if there is a more "elegant" or easier to understand way to do this?

I have more questions, but I'll start with this one.

Thanks! Jan

Viewing all articles
Browse latest Browse all 3029

Latest Images

Trending Articles



Latest Images