Hi,

I am new to this website (and C++) so pls forgive any newb errors / convention mistakes.

I have a project that contains both a normal source file (PB.cpp), associated header (PB.h) and a windows form (GUI.h). I'm trying to pass a variable from the form to a function in PB.cpp but i get the error:
c:\bot\pb\pb\GUI.h(419): error C2660: 'funcdec' : function does not take 1 arguments
A simplified version of the problem is below:

PB.h:

int funcdiv();

PB.cpp:

#include "stdafx.h"
#include <iostream>
#include "GUI.h"

using namespace std;
using namespace System::Drawing;
using namespace PB;

int funcdiv(int x)
{
int y = x/2;
return y;
}

int _tmain(int argc, _TCHAR* argv[])
{
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false); 
	Application::Run(gcnew GUI());
	return 0;
}

GUI.h:

#pragma once 
#include "stdafx.h" 
#include <iostream>
#include "PB.h"

namespace PB { 
        public ref class GUI : public System::Windows::Forms::Form 
        { 
<code>
        public: 
                GUI(void) 
                { 
<code> 
			int z = 100;
			int a = funcdiv(z);
			cout<<a<<endl;
                } 
<code>
        } 
<code>
}

PB.cpp uses ADO to reference a database so i'd prefer to keep the structure of the project with PB.cpp and GUI.h separate.

From what i have read this has something to with having compatability issues between managed code and native code. Is it possible to transfer variables in this way? If not is there a workaround? Any help would be appreciated.

(code written in Visual Studio 2010)

Edited 6 Years Ago by carrythe1: n/a

well

int funcdiv();

is the problem, you need to pass somthing.

funcdiv needs an int.

int funcdiv(int x)
{
int y = x/2;
return y;
}

try

funcdiv(5);

Edited 6 Years Ago by finito: n/a

Obv new to this but wasn't even thinking about that as an issue.

Thanks for the help!

This question has already been answered. Start a new discussion instead.