|
That looks like a static class to me
Cheers,
Mark
This episode brought to you by the letter N
|
|
|
|
|
Hi
I am trying to make a detour wrapper class and so i have created some template functions and classes. These are the classes(in simplified form):
Header File:
<br />
#ifndef DETOUREME_H<br />
#define DETOUREME_H<br />
<br />
#include "..\..\..\stdafx.h"<br />
<br />
HRESULT WINAPI somefunction( void );<br />
<br />
class DetourWrapper<br />
{<br />
public:<br />
DetourWrapper(void){};<br />
~DetourWrapper(void){};<br />
<br />
template<typename H> BOOL isDetoured ( H* pClass, int iType );<br />
};<br />
<br />
class DetourThis<br />
{<br />
public:<br />
DetourThis(){};<br />
~DetourThis(){};<br />
<br />
virtual BOOL isDetoured( void ){ return TRUE; };<br />
};<br />
<br />
extern DetourWrapper g_pDW;<br />
extern DetourThis *d_pDT;<br />
<br />
#endif
CPP File:
<br />
#include "Debug.h"<br />
<br />
extern DetourWrapper g_pDW;<br />
extern DetourThis *d_pDT = NULL;<br />
<br />
template<typename H> BOOL DetourWrapper::isDetoured ( H* pClass, int iType )<br />
{<br />
return pClass->isDetoured();<br />
}<br />
<br />
HRESULT WINAPI somefunction( void )<br />
{<br />
d_pDT = new DetourThis;<br />
BOOL enabled = g_pDW.isDetoured(d_pDT, 2);<br />
}
Error:
Linking...<br />
Debug.obj : error LNK2001: unresolved external symbol "class DetourWrapper g_pDW" (?g_pDW@@3VDetourWrapper@@A)<br />
C:\Documents and Settings\Steal.Patrick\My Documents\Visual Studio 2005\Projects\Detours\Release\Detour.dll : fatal error LNK1120: 1 unresolved externals
Can someone please tell me what i am doing wrong here?
Thanks
|
|
|
|
|
I have linked my C/C++ static libraries compiled in VS2005 to my C++/CLI interop project, I want to use C++/CLI interop to export this functionality to C# client.
If i put a call to any static lib function in this interop project, The Interop project compiles properly but gives runtime error
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!
Program: ...
File: dbgheap.c
Line: 1473
Expression: _CrtIsValidHeapPointer(pUserData)
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
Do I need to initialize CRT or somthing in the interop project
If i use a test static lib (static lib created for testing purpose by me) everything works fine, problem occurs when I link my products static libraries and try to call a function from these static lib in my interop project
Subodh Borker
|
|
|
|
|
Hello Subodh,
One clean solution would be to wrap your static library into the regular DLL, which can then be used within the CLI project.
|
|
|
|
|
I am using Visual c++. Net 2005 with sql server 2000 database.
If I change or add new fields in tables; who can I refresh my Dataset object
|
|
|
|
|
By doing a request for data from the DB, again.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Bonjour,
i introduce a laibrairie in my project, whene i compile there are error :
D:\Program Files\Microsoft Visual Studio 8VC\PlatformSDK\include\wspiapi.h : (44)error C2894: templates cannot be declared to have 'C' linkage
please help me to resolve this pb.
Thank you verry mutch
|
|
|
|
|
Doesn't look like a CLI question to me, have you tried the visual C++ forum ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
In my form a have one datagridView to show all data from my table. And I have textboxes from where I changed data on my table when I click on a button "save".
Now I want those changes can be shown immediately on my datagridView without leaving the form and return.
What can I do so to refresh datagridview datasource programmaticcaly .
|
|
|
|
|
I think there is a Refresh method you can call.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Refresh don't working
The solution is to bind again datasource
|
|
|
|
|
Hi
is it possible to declare a vector with a name that we read from a file or cin?
thanks
|
|
|
|
|
I think you're in the wrong forum, you're asking about standard C++ stuff, not .NET. Either way, the answer is no. You can't make a variable name dynamic, and why on earth would you ? You can create a map of strings to vectors, and name them that way.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
yes i think i m in the wrong place...
What do you mean with you can create a map of strings to vectors, and name them that way.
thanks
|
|
|
|
|
map<string, vector<myType> > myTypes;
myTypes["fish"] // reference a myType named fish
Not sure if you need to use pointers to make it initialise, or not. Long time since I did this in C++
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
map<string, vector<mytype=""> > myTypes;
myTypes["fish"] // reference a myType named fish
Hi
Sorry for the ignorance, I'm new to c++. Is there a way to call the myTypes["fish"] from a cin?
for example use cin to read a string(num) and call the cout<
|
|
|
|
|
I recommend reading about the map/dictionary/hashtable ( they are all the same thing ) type of container. In a nutshell, map<x,y> is a container where you use an object of type x, to map to an object of type y. So, map<string, int> would mean that myMap["string"] returns an int, and can be put anywhere that an int is expected.
You may need to store a pointer, so that you can set values on it, I'm not sure if a copy by value would otherwise occur. Like I said, I"m rusty on the details.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: I'm not sure if a copy by value would otherwise occur.
The standard memberwise copy would be used unless you override it.
|
|
|
|
|
yeah, I thought so, but I wasn't sure. Lots of cobwebs in that part of the brain....
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have a text file which has data written to it.. If I open the file, how would I read the data in the file one line at a time, then do something with the data, then read the next line etc
Thanks for your help!
--PerspX
|
|
|
|
|
File.ReadAllLines will return the text as a string array. Assuming you meant to ask in the .NET C++ forum ( which you have )
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I'm getting really confused by trivial properties. Can someone explain this to me:
#include "stdafx.h"
using namespace System;
ref class Foo
{
public:
Foo()
{
data = 0;
s = "default";
}
Foo(int d, String^ in)
{
data = d;
s = in;
}
virtual String^ ToString() override
{
return "Data: " + this->Data + " S: " + this->S;
}
property int Data
{
int get()
{
return data;
}
void set(int d )
{
data = d;
}
}
property String^ S
{
String^ get()
{
return s;
}
void set(String^ in)
{
s = in;
}
}
int data;
String^ s;
};
int main(array<System::String ^> ^args)
{
Foo f;
Foo b(1, "hello");
Foo ^c = gcnew Foo(5, "world");
Console::WriteLine(f.data + " " + f.s->ToString());
Console::WriteLine(b.data + " " + b.s->ToString());
Console::WriteLine(c->data + " " + c->s->ToString());
Console::WriteLine(f.Data + " " + f.S->ToString());
Console::WriteLine(b.Data + " " + b.S->ToString());
Console::WriteLine(c->Data + " " + c->S->ToString());
Console::WriteLine(f.ToString());
Console::WriteLine(b.ToString());
Console::WriteLine(c->ToString());
return 0;
}
I'm so confused.
On a similar note, I have another code sample where I'm writing a very basic copy constructor for a ref class (with a single int data member) and if I use a trivial or explicit property the copy constructor works. If I remove the property declaration entirely and just access the data member (when its public), it works. But if I have the property declared (explicitly or trivially) then I can't set the data member in the copy constructor by accessing the member itself. I have to use the property name otherwise it sets it to 0.
|
|
|
|
|
Maybe I'm missing something, but how can you expect to read a property if you omit the getter
function?
Also, is using ToString on a String redundant?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
Unless I'm horribly mistaken... Declaring the trivial property as follows:
property int Data;
should tell the compiler to generate something to the effect of:
property int Data
{
int get()
{
return data;
}
void set(int d)
{
data = d;
}
}
using a ' < backing_store > Data' variable behind the scenes.
Likewise for
property String^ S That's the whole point of trivial properties as I understood it. If you're just making a 'trivial' getter and setter with no validation then the trivial property declaration should accomplish what you need and save you from typing a few lines of code. At least that's what I gathered from http://www.codeproject.com/managedcpp/CppCliProperties.asp?df=100&forumid=179807&exp=0&select=1107337 and many other articles/books.
And yes, that was a little redundant I've been staring at this property stuff for so long I'm making some dumb mistakes and triple checking everything before I post it.
-- modified at 18:18 Tuesday 3rd July, 2007
|
|
|
|
|
It's me that's horribly mistaken.
When you initialize the trivial proprties in your constructors, you need to use the trivial
property names:
Foo()
{
Data = 0;
S = "default";
}
Foo(int d, String^ in)
{
Data = d;
S = in;
}
...
property int Data;
property String^ S;
Mark
Mark Salsbery
Microsoft MVP - Visual C++
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|