|
You simply cannot call func1 from main, if main is in another file.
That is what static is for, to prevent a function from being seen
outside its definition file.
So remove the static keyword and it will compile.
(Assuming there's no other problem )
BTW you should rather use a class member function (in this case static would be ok).
|
|
|
|
|
I have the following in a c++/cli library project
template<typename T>
public ref class BaseTemplateClass
{
public:
BaseTemplateClass()
{
}
void BaseClassFunction()
{
}
};
public ref class DerivedClass : public BaseTemplateClass<System::Int32>
{
public:
DerivedClass()
{
}
void DerivedClassFunction()
{
}
};
In My c# client if I type
DerivedClass d = new DerivedClass();
d.
The little popup window appears with the method list and it does not contain BaseClassFunction().
If I type the name manually it works fine. Any ideas why I cant see the method from the template base class in the code complettion window?
|
|
|
|
|
Metadata is not produced for template functions and template classes.
|
|
|
|
|
Thanks George,
Is there any way to overcome this? I am only using the templates in the managed c++ lib so all the classes are generated from the template at compile time.
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
http://msdn2.microsoft.com/en-gb/library/sbh15dya.aspx[^]:
<quote>The common language runtime specifically supports generics in MSIL. Because the runtime knows about generics, specific types can be substituted for generic types when referencing an assembly containing a generic type. Templates, in contrast, resolve into ordinary types at compile time and the resulting types may not be specialized in other assemblies.
There is no real solution unless you can mix generics with templates for C# and VB, or wrap the template code.
|
|
|
|
|
George L. Jackson wrote: Templates, in contrast, resolve into ordinary types at compile time and the resulting types may not be specialized in other assemblies
Yeah thats why I would have expected the compiler to produce the metadata. Thanks again for your help
I just want to avoid a situation where our c# team ask me everyday "why cant I see those methods" or "this class doesnt have that method"
System.IO.Path.IsPathRooted() does not behave as I would expect
|
|
|
|
|
|
Hi, All
In one function of my project I need a 2-D vector array consisting of elements of struct STRU_A.
struct STRU_A{
char ch[20];
float score;
};
However, the two dimensions both dynamic. That is, the dimension sizes depend on the input to the function.
How to declare and retrieve a 2-D vector array of such kind.
thank you
|
|
|
|
|
If this was the C++ forum, I'd say vector< vector< STRU_A> > myVec; I'd probably also point out to be careful to not put the two > next to each other ( you need a space, >> is an operator ). But, it's the C++/CLI forum, so I can't help
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
If this was the C++ forum and you had answered the correctly posted question, I would have made a hypothetical comment that the Visual Studio 2005 version of C++ does allow you to write vector<vector<STRU_A>> without the space! However, since none of this has happened, you can respectively ignore what I may have allegedly said.
|
|
|
|
|
Wow - that's cool. Wish I'd posted in the right place, so I could have learned that.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi
I need to know the method to fill the ListView with my database contents. I tried with the help of the Dataset, but could not find any solution to it.
I am not able to populate the list view with my dataset contents.
Please send me any sample code to solve this problem.
Kindly do me a favour by helping me to find the solution to this.
Thank you
-- modified at 4:36 Tuesday 5th December, 2006
Kind Regards
Sandy
|
|
|
|
|
Here is a code snippet that i have used to update the listview from a DataSet. This snippet goes the each row in the dataset (in my case myDataSet) and Creates a ListViewItem to add to your ListView Control (in my case myListView1).
for each (DataRow^ r in myDataSet->Tables[0]->Rows)
{
ListViewItem^ lvindex = gcnew ListViewItem(r[0]->ToString());
ListViewItem::ListViewSubItem^ sublvindex = gcnew ListViewItem::ListViewSubItem(lvindex,r[1]->ToString());
myListView1->SubItems->Add(sublvindex);
sublvindex = gcnew ListViewItem::ListViewSubItem(lvindex,r[2]->ToString());
myListView1->SubItems->Add(sublvindex);
myListView1->Items->Add(lvindex);
}
hope this helps.
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
I am really greatfull to you for the support replay...
But i guess the code is not for VC++.Net, I need to it in managed C++, where i am not able to use the keywords like "for Each" & Table[0]->. I am geeting error for this code.
Can you kindly tell me if there is a problem with my code or else i need alter the code provided by you...
Please do me a favour by giving me this piece of Info.
Thanks a lot
Kind Regards
Sandy
|
|
|
|
|
Yes, this snippet is for Managed C++. Please post your code and copy the errors your getting from the error window and i'll see if i can fix it.
Thanks
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Hi,
Yeah kindly find the list of errors below which are fired when i use this piece of code.
This is my code :
private: System::Void Form1_Load(System::Object * sender, System::EventArgs e)
{
System::String * SqlStr;
ListView * listView1 = new ListView();
try
{
SqlStr = "Select IC, Part_Code, PART_NUMBER, PART_NAME from vdcsssp_PARTS_mst" ;
SqlCommand* objCmd = new SqlCommand();
SqlDataAdapter* objDA = new SqlDataAdapter();
DataSet* objDS = new DataSet();
SqlConnection* objCon = new SqlConnection();
objCon->ConnectionString = "User ID=sa;pwd=qil2004;Data Source=qipl-server;Initial Catalog=Qvdcsssp";
if(objCon->get_ConnectionString() != "")
{
objCon->Open();
objCmd->CommandText = SqlStr;
objCmd->Connection = objCon;
objDA->SelectCommand = objCmd;
objDA->Fill(objDS);
}
else
MessageBox::Show("Error connection Failed");
return;
for each (DataRow* r in objDS->Tables[0]->Rows)
{
//Create a listView Item and add the first column of the dataset to it
ListViewItem* lvindex = gcnew ListViewItem(r[0]->ToString());
//Create a subitem and add the seconed column to it
ListViewItem::ListViewSubItem* sublvindex = gcnew ListViewItem::ListViewSubItem(lvindex,r[1]->ToString());
//Add the 1st subitem to the listview item
listView1->SubItems->Add(sublvindex);
//Create the seconed ListView SubItem and add the third column of the Dataset to it.
sublvindex = gcnew ListViewItem::ListViewSubItem(lvindex,r[2]->ToString());
//Add the 2nd subitem to the listview item
listView1->SubItems->Add(sublvindex);
//Add the entire ListViewItem to the next available row in myListView
listView1->Items->Add(lvindex);
}
}
catch(Exception* ex)
{
MessageBox::Show(ex->Message);
}
-----------------------------------------------------------------------------
This is my errors:
e:\Sandeep\VC++ .Net\Test1\Form1.h(376) : error C2061: syntax error : identifier 'each'
e:\Sandeep\VC++ .Net\Test1\Form1.h(377) : error C2143: syntax error : missing ';' before '{'
e:\Sandeep\VC++ .Net\Test1\Form1.h(379) : error C2065: 'gcnew' : undeclared identifier
e:\Sandeep\VC++ .Net\Test1\Form1.h(379) : error C2146: syntax error : missing ';' before identifier 'ListViewItem'
e:\Sandeep\VC++ .Net\Test1\Form1.h(379) : error C2065: 'r' : undeclared identifier
e:\Sandeep\VC++ .Net\Test1\Form1.h(379) : error C2227: left of '->ToString' must point to class/struct/union
e:\Sandeep\VC++ .Net\Test1\Form1.h(381) : error C3861: 'gcnew': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(381) : error C2143: syntax error : missing ';' before 'System::Windows::Forms::ListViewItem::ListViewSubItem'
e:\Sandeep\VC++ .Net\Test1\Form1.h(381) : error C2227: left of '->ToString' must point to class/struct/union
e:\Sandeep\VC++ .Net\Test1\Form1.h(381) : error C3861: 'r': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(383) : error C2039: 'SubItems' : is not a member of 'System::Windows::Forms::ListView'
stdafx.cpp(0) : see declaration of 'System::Windows::Forms::ListView'
e:\Sandeep\VC++ .Net\Test1\Form1.h(383) : error C2227: left of '->Add' must point to class/struct/union
e:\Sandeep\VC++ .Net\Test1\Form1.h(385) : error C2143: syntax error : missing ';' before 'System::Windows::Forms::ListViewItem::ListViewSubItem'
e:\Sandeep\VC++ .Net\Test1\Form1.h(385) : error C3861: 'gcnew': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(385) : error C2227: left of '->ToString' must point to class/struct/union
e:\Sandeep\VC++ .Net\Test1\Form1.h(385) : error C3861: 'r': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(387) : error C2039: 'SubItems' : is not a member of 'System::Windows::Forms::ListView'
stdafx.cpp(0) : see declaration of 'System::Windows::Forms::ListView'
e:\Sandeep\VC++ .Net\Test1\Form1.h(387) : error C2227: left of '->Add' must point to class/struct/union
Kind Regards
Sandy
|
|
|
|
|
 I think (don't quote me on it) the problem was that you were trying to create a control using a pointer (*) and that is why alot of the error's came up. The snippet below compiled fine for me give it a try and let me know how it works for you. If you have anymore problems you can also email me djcarter2326@aim.com. I'm more used to using C# but i am teaching myself Managed C++.
System::String ^ SqlStr;
ListView ^ listView1 = gcnew ListView();
try
{
SqlStr = "Select IC, Part_Code, PART_NUMBER, PART_NAME from vdcsssp_PARTS_mst" ;
SqlCommand^ objCmd = gcnew SqlCommand();
SqlDataAdapter^ objDA = gcnew SqlDataAdapter();
DataSet^ objDS = gcnew DataSet();
SqlConnection^ objCon = gcnew SqlConnection();
objCon->ConnectionString = "User ID=sa;pwd=qil2004;Data Source=qipl-server;Initial Catalog=Qvdcsssp";
if(objCon->ConnectionString != "")
{
objCon->Open();
objCmd->CommandText = SqlStr;
objCmd->Connection = objCon;
objDA->SelectCommand = objCmd;
objDA->Fill(objDS);
}
else
MessageBox::Show("Error connection Failed");
return;
for each (DataRow^ r in objDS->Tables[0]->Rows)
{
ListViewItem^ lvindex = gcnew ListViewItem(r[0]->ToString());
ListViewItem::ListViewSubItem^ sublvindex = gcnew ListViewItem::ListViewSubItem(lvindex,r[1]->ToString());
lvindex->SubItems->Add(sublvindex);
sublvindex = gcnew ListViewItem::ListViewSubItem(lvindex,r[2]->ToString());
lvindex->SubItems->Add(sublvindex);
listView1->Items->Add(lvindex);
}
}
catch(Exception^ ex)
{
MessageBox::Show(ex->Message);
}
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Hi
I dont know if i can use the char '^' works here i am getting errors on using this...
The errors are...
e:\Sandeep\VC++ .Net\Test1\Form1.h(386) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(386) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(387) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(387) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(390) : error C2065: 'SqlStr' : undeclared identifier
e:\Sandeep\VC++ .Net\Test1\Form1.h(391) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(391) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(392) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(392) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(393) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(393) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(394) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(394) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(399) : error C3861: 'SqlStr': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(407) : error C2061: syntax error : identifier 'each'
e:\Sandeep\VC++ .Net\Test1\Form1.h(408) : error C2143: syntax error : missing ';' before '{'
e:\Sandeep\VC++ .Net\Test1\Form1.h(410) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(410) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(412) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(412) : error C2143: syntax error : missing ';' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(414) : error C2065: 'lvindex' : undeclared identifier
e:\Sandeep\VC++ .Net\Test1\Form1.h(414) : error C2227: left of '->SubItems' must point to class/struct/union
type is ''unknown-type''
e:\Sandeep\VC++ .Net\Test1\Form1.h(414) : error C2227: left of '->Add' must point to class/struct/union
e:\Sandeep\VC++ .Net\Test1\Form1.h(414) : error C2065: 'sublvindex' : undeclared identifier
e:\Sandeep\VC++ .Net\Test1\Form1.h(416) : error C2065: 'gcnew' : undeclared identifier
e:\Sandeep\VC++ .Net\Test1\Form1.h(416) : error C2143: syntax error : missing ';' before 'System::Windows::Forms::ListViewItem::ListViewSubItem'
e:\Sandeep\VC++ .Net\Test1\Form1.h(416) : error C3861: 'sublvindex': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(416) : error C2065: 'r' : undeclared identifier
e:\Sandeep\VC++ .Net\Test1\Form1.h(416) : error C2227: left of '->ToString' must point to class/struct/union
e:\Sandeep\VC++ .Net\Test1\Form1.h(416) : error C3861: 'lvindex': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(418) : error C2227: left of '->SubItems' must point to class/struct/union
type is ''unknown-type''
e:\Sandeep\VC++ .Net\Test1\Form1.h(418) : error C2227: left of '->Add' must point to class/struct/union
e:\Sandeep\VC++ .Net\Test1\Form1.h(418) : error C3861: 'lvindex': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(418) : error C3861: 'sublvindex': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(420) : error C3861: 'lvindex': identifier not found, even with argument-dependent lookup
e:\Sandeep\VC++ .Net\Test1\Form1.h(423) : error C3149: 'System::Exception' : illegal use of managed type 'System::Exception'; did you forget a '*'?
e:\Sandeep\VC++ .Net\Test1\Form1.h(423) : error C2143: syntax error : missing ')' before '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(423) : error C2725: 'System::Exception' : unable to throw or catch a __gc type object by value or reference
e:\Sandeep\VC++ .Net\Test1\Form1.h(423) : error C2316: 'System::Exception' : cannot be caught as the destructor and/or copy constructor are inaccessible
e:\Sandeep\VC++ .Net\Test1\Form1.h(423) : error C2319: 'catch' must be followed by a compound statement. Missing '{'
e:\Sandeep\VC++ .Net\Test1\Form1.h(423) : error C2059: syntax error : '^'
e:\Sandeep\VC++ .Net\Test1\Form1.h(423) : error C2059: syntax error : ')'
e:\Sandeep\VC++ .Net\Test1\Form1.h(424) : error C2143: syntax error : missing ';' before '{'
e:\Sandeep\VC++ .Net\Test1\Form1.h(425) : error C2065: 'ex' : undeclared identifier
e:\Sandeep\VC++ .Net\Test1\Form1.h(425) : error C2227: left of '->Message' must point to
Kind Regards
Sandy
|
|
|
|
|
How can i know the WDFDEVICE details of any device.
WDFDEVICE is A handle to a framework device object
|
|
|
|
|
Hi all,
How do I export functions from a .c externsion file say, app.c file( there is an app.h file too)to a test.c file??
All the file extensions are .c and iam using gcc to compile. Iam doing C not C++.
I do in test.h file the following:
#ifndef _TEST_H<br />
#define _TEST_H<br />
<br />
extern void func1(void);<br />
<br />
#endif /* _TEST_H */
but the compiler returns with an error:
test.h:4: warning: function declaration isn't a prototype
Can anyone help me with whats happening that will help me understand much better on exporting functions.
Thanks in advance.
-- modified at 2:35 Monday 4th December, 2006
|
|
|
|
|
|
ROTFL !!!
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
There's nothing more annoying than when someone asks clueless questions, and when you try to help them anyhow, they don't answer you, and delete all their posts.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I feel your pain and have seen your effort to help even the clueless. Many of them want to obtain knowledge and information without paying the price of learning something. If they don't understand where they need help, all of our assistance is lost in their dark clueless void of educational enlightenment. However, there is always joy when you actually see your assistance light a candle.
Geo
|
|
|
|
|
This would take me about 5 minutes to write, about the same amount of time I'll spend on this post.
Here's why I didn't write the code for you.
There's about a 3% chance that your teacher won't notice that you've passed in production quality code, but aren't smart enough to post your homework questions in the right forum ( or to just post them once). But, some people are lucky. If you were to pass your course, there's a slim chance that I'll find myself with a lazy and clueless co-worker.
My plea to you - if you can't be bothered learning basic C++, change courses, or just apply at McDonalds and be done with it.
If, on the other hand, you try to do your own homework, and ask specific questions if you get stuck, I'll be the first to try to help.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|