How i put a CArray as a parament in a function
-
Hello i have a function OnStart(){} and inside this function there is a CArray FArray that contains Filepathnames. i want to create a function that take as a parametr CArray (so i can execute it inside OnStart() ) I try to create but when i put FindDF(CArray nArray) it says me i cant put < >
-
Hello i have a function OnStart(){} and inside this function there is a CArray FArray that contains Filepathnames. i want to create a function that take as a parametr CArray (so i can execute it inside OnStart() ) I try to create but when i put FindDF(CArray nArray) it says me i cant put < >
You need to have something like this: FindDF(const CArray& filepathnames)
Kevin
-
You need to have something like this: FindDF(const CArray& filepathnames)
Kevin
:( i put Find ( CString file , const CArray& FArray) c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(18) : error C2143: syntax error : missing ',' before '&' c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(18) : error C2059: syntax error : '&' C:\Program Files\Microsoft Visual Studio\MyProjects\Anaktisi\AnaktisiDlg.cpp(850) : error C2955: 'CArray' : use of class template requires template argument list c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(238) : see declaration of 'CArray' C:\Program Files\Microsoft Visual Studio\MyProjects\Anaktisi\AnaktisiDlg.cpp(851) : error C2511: 'Find' : overloaded member function 'double (class CString,const class CArray &)' not found in 'CAnaktisiDlg' c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(14) : see declaration of 'CAnaktisiDlg'
-
Hello i have a function OnStart(){} and inside this function there is a CArray FArray that contains Filepathnames. i want to create a function that take as a parametr CArray (so i can execute it inside OnStart() ) I try to create but when i put FindDF(CArray nArray) it says me i cant put < >
Since CArray is a template class, you need to declare your array type as such. You can either use something like this CArray or to shorten things up, use typedef to create an alias for the template class: typedef CArray CArrayMembersClassArray; and use "CArrayMembersClassArray" as a variable type. Mark "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Since CArray is a template class, you need to declare your array type as such. You can either use something like this CArray or to shorten things up, use typedef to create an alias for the template class: typedef CArray CArrayMembersClassArray; and use "CArrayMembersClassArray" as a variable type. Mark "Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
i tried FindDF(CString file , CArray < CString, CString& > FArray) and when i press OK nothing happends (pressed it many times)
-
i tried FindDF(CString file , CArray < CString, CString& > FArray) and when i press OK nothing happends (pressed it many times)
I'm sorry...what? :confused: What do you mean you "press ok"? Runtime? Design time? I'm lost :) Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
I'm sorry...what? :confused: What do you mean you "press ok"? Runtime? Design time? I'm lost :) Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
hehehe sorry i let you alone inside forest:D Ok here i am to rescue u ! i use Microsoft Visual studio C++ 6.0 enviroment i press right click on the Class and press Add member function on the window it pop up i time Type: double Function declaration : Find(CString file , ....) and i have to press OK or cancel :D
-
hehehe sorry i let you alone inside forest:D Ok here i am to rescue u ! i use Microsoft Visual studio C++ 6.0 enviroment i press right click on the Class and press Add member function on the window it pop up i time Type: double Function declaration : Find(CString file , ....) and i have to press OK or cancel :D
Ohhh ok :) I've never used the add function wizard but I just tried it on VS 2003 .NET. I chose "Add/Add function.." for a class. Selected a return type typed a function name for the parameter type, I typed "CArray<int, int&> &" parameter name I typed MyIntArray clicked the Add button to add the parameter clicked Finish and the function was added to my class I'm not sure how different that is from VC 6 (I bet David Crow knows :)) Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Ohhh ok :) I've never used the add function wizard but I just tried it on VS 2003 .NET. I chose "Add/Add function.." for a class. Selected a return type typed a function name for the parameter type, I typed "CArray<int, int&> &" parameter name I typed MyIntArray clicked the Add button to add the parameter clicked Finish and the function was added to my class I'm not sure how different that is from VC 6 (I bet David Crow knows :)) Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
double CAnaktisiDlg::FindDF(CString file , CArray < CString, CString& > &FArray) is what i create (indetifier CArray error) double CAnaktisiDlg::FindDF(CString file , CArray < CString, CString& > FArray) same :/ according to you it had to be working fine :((
-
:( i put Find ( CString file , const CArray& FArray) c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(18) : error C2143: syntax error : missing ',' before '&' c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(18) : error C2059: syntax error : '&' C:\Program Files\Microsoft Visual Studio\MyProjects\Anaktisi\AnaktisiDlg.cpp(850) : error C2955: 'CArray' : use of class template requires template argument list c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(238) : see declaration of 'CArray' C:\Program Files\Microsoft Visual Studio\MyProjects\Anaktisi\AnaktisiDlg.cpp(851) : error C2511: 'Find' : overloaded member function 'double (class CString,const class CArray &)' not found in 'CAnaktisiDlg' c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(14) : see declaration of 'CAnaktisiDlg'
Immunity18 wrote:
c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(18) : error C2143: syntax error : missing ',' before '&'
Did you forget
#include <afxtempl.h>
in your project'sstdafx.h
file?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
:( i put Find ( CString file , const CArray& FArray) c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(18) : error C2143: syntax error : missing ',' before '&' c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(18) : error C2059: syntax error : '&' C:\Program Files\Microsoft Visual Studio\MyProjects\Anaktisi\AnaktisiDlg.cpp(850) : error C2955: 'CArray' : use of class template requires template argument list c:\program files\microsoft visual studio\vc98\mfc\include\afxtempl.h(238) : see declaration of 'CArray' C:\Program Files\Microsoft Visual Studio\MyProjects\Anaktisi\AnaktisiDlg.cpp(851) : error C2511: 'Find' : overloaded member function 'double (class CString,const class CArray &)' not found in 'CAnaktisiDlg' c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(14) : see declaration of 'CAnaktisiDlg'
Here's an example of how to pass an array argument from the CArray implementation in afxtempl.h
INT_PTR CArray::Append(const CArray& src)
{
ASSERT_VALID(this);
ASSERT(this != &src); // cannot append to itselfif(this == &src) AfxThrowInvalidArgException(); INT\_PTR nOldSize = m\_nSize; SetSize(m\_nSize + src.m\_nSize); CopyElements(m\_pData + nOldSize, src.m\_pData, src.m\_nSize); return nOldSize;
}
Kevin
-
Immunity18 wrote:
c:\program files\microsoft visual studio\myprojects\anaktisi\anaktisidlg.h(18) : error C2143: syntax error : missing ',' before '&'
Did you forget
#include <afxtempl.h>
in your project'sstdafx.h
file?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
#include "stdafx.h" its the first of my include
-
#include "stdafx.h" its the first of my include
Immunity18 wrote:
#include "stdafx.h" its the first of my include
:confused: Meaning what?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
double CAnaktisiDlg::FindDF(CString file , CArray < CString, CString& > &FArray) is what i create (indetifier CArray error) double CAnaktisiDlg::FindDF(CString file , CArray < CString, CString& > FArray) same :/ according to you it had to be working fine :((
Works for me but I'm on a different VS version. I also have included afxtempl.h in my projects, although I'm not sure if the wizard uses that... You can always add the function by hand :) Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Immunity18 wrote:
#include "stdafx.h" its the first of my include
:confused: Meaning what?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
i because it was it wasn't visible and i thought u said did you forget to #include , in your project, the "stdafx.h" file ? And yes i didnt #include "afxtempl.h" but not that i forget ,because i didnt know i had :P
-
Immunity18 wrote:
#include "stdafx.h" its the first of my include
:confused: Meaning what?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
Now i include it my double CAnaktisiDlg::FindDF(CString file , CArray < CString, CString > FArray) works fine thank you onces again David :D (both kevin and mark :D)