|
I m using a Access database with ODBC connesction.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
And -1 is all that's in the thrown exception object? No strings?
I know SQL server returns pretty useful error strings that are placed
in the CDBExceptions....not sure about Access.
You can always step into the Open() call and see where it's failing.
There's lots of potential reasons...
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Now its resolveed,
Thanks sir
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Hello,
Pardon me, its a pure question of C/C++ not specific to Visual C++. Can anybody explain what is the purpose of following code:
void Function1(int a, int b)
{
void Function2(int c, int d, int e); // in some header file
void Function3(int c, int d, int e); // in some header file
int i, k, l;
//rest of the code in which Function2 and Function3 are being used!
}
I have no idea why "Function2" & "Function3" prototypes are defined in the function named "Function1", and is it possible? If yes whats the logic behind it?
Any help is highly appreciated.
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
This is just a function declaration. Its purpose is to tell the compiler that in some other place( may be in another file or in the same file ) we have a function defined with name Function2 and Function3 with following prototype. Other wise the compiler will thow compilation error saying the Function2 and Function3 cannot be found.
|
|
|
|
|
That means, logically it is equal to:
void Function2(int c, int d, int e);
void Function3(int c, int d, int e);
void Function1(int a, int b)
{
//actual code
}
Right?
Regards,
Adeel
Do rate the reply, if it helps or even if it doesnot, because it helps the members to know, what solved the issue. Thanks.
|
|
|
|
|
Ya almost. But the difference is that, now all the functions after the Function1 will be aware of the Function2 and Function3.
If the declation was inside the Function1, only Function1 will be aware of the Function2 and Function3. Trying to call those functions from any other function will create compilation error. That is the scope of the declaration is restricted to the body of Function1.
|
|
|
|
|
I am using following libraries to calculate MAC address and IP address. when i run my program it works fine but when i makes its setup and install on such system wher VC is not install then program does not run it just generate exaption and no output. before adding work of calculation of MAC my set was working properly
library files are
ws2_32.lib
snmpapi.lib
inetmib1.dll
in inosetup i am including these like
Source: "C:\windows\system32\ws2_32.DLL"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\windows\system32\snmpapi.DLL"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\inetmib1.DLL"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Program Files\Microsoft Visual Studio\VC98\Lib\ws2_32.lib"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\Program Files\Microsoft Visual Studio\VC98\Lib\snmpapi.lib"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
|
|
|
|
|
Look for Microsoft redistributables (libraries that come with the compiler that are needed to make programs function corectly). These are freely redistributable hence the name. Get the ones that go with the compiler you are using.
|
|
|
|
|
can any tell me what is the difference between c# and c++ structs..
Santhapur
|
|
|
|
|
I have only a small idea about .net and what I understand is..
In both c++ and c#, strctures and class are used for grouping memeber variables. How ever when you create a object of strcture in c#, it is created in stack and when you create a class object, it is created in heap.
In c++, the structre or class dosent have much dIfference. But if you create it uisng the new, it is created in heap and simply declaring it creates the objects in the stack.
Please correct me if am wrong....
|
|
|
|
|
Structs are used in both languages to encapsulate related variables.
Structs differ between C++ and C# in how they compare with classes.
In C#, a struct is a value type, while a class is a reference type.
In the managed world, there are value types, which can be and most often are
stored on the stack (or as a member of a class) and reference types which are always
allocated on a heap. In C#, a struct is a value type, while a class is a reference type.
This is an important concept in C# - for example, when you pass a struct as a function parameter,
it is passed by value, so if the function changes the struct, the original passed object is
untouched. When a class object is passed it is by reference, so any changes made by the function
change the original object. That difference is why C# doesn't need *, &, and -> operators all
over the place.
In the native C++ world, structs and classes are the same except for default
member access. Both can be allocated on the stack or the heap. Reference and
value are controlled by operators, like *, &, ., and ->
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
And what is the difference between a C# class and a C++ one?
And what about the new keyword?
Hey, is there also any difference on the inheritance paradigm?
...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Getting soft... I was expecting:
CPallini shoulda wrote:
About 3 characters.
|
|
|
|
|
You're great.
Anyway, that's right: I feel a bit weak this morning.
BTW welcome in the THHB .
(Official investiture on my blog [^].)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can someone take a look at my code to see what I'm doing wrong.
int score;<br />
char grade =0;<br />
<br />
<br />
cout << endl;<br />
cout << "Enter total score (float, must be <= 100): "; <br />
cin >> score; <br />
<br />
if (score >= 85); <br />
grade = 'A';<br />
else if (score >= 75); <br />
grade = 'B';<br />
else if (score >= 65); <br />
grade = 'C';<br />
else if (score >= 55);<br />
grade = 'D';<br />
else <br />
grade = 'F';<br />
End if
End if
End if
End if
<br />
<br />
<br />
<br />
cout << endl; <br />
cout << "Your grade for CMSC 101 is: " << grade << endl; <br />
return (0);
|
|
|
|
|
dtaylor01 wrote: if (score >= 85);
else if (score >= 75);
else if (score >= 65);
else if (score >= 55);
remove the semi colon's at the end of if statement and else if statement...
|
|
|
|
|
In addition to Naveen reply:
dtaylor01 wrote: End if
There's not an End if keyword in C/C++ .
Bottom line: Good C/C++ tutorial required.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
You've been given answers to the problems I can see (and I didn't catch the ; first).
But you didn't need us to tell you about them - any compiler would have choked on your code, and treated you to a barrage of bad language. Those errors are your (sarcastic picky) friend. Apart from anything else, people who come here to help expect you to have done some of the heavy lifting already.
1/ "else"? whatdaya mean "else". There should be an if first!
would have given you a hint towards the ; Not an easy hint one though.
I personally dislike using the style for very trivial ifs, but many people insist on putting squiggly brackets round every if case, which will make it easier for you while starting. It also makes it harder to make an error when you add more than one line to and if case.
eg:
if (score > 85)
{
grade = 'A';
}
else if (score >= 75)
{
2/ "end"? Never heard of it.
Easy hint.
|
|
|
|
|
Hi.I'm trying to compile a project with Visual Studio 2008, but I need to modify my linker settings to include wsock32.lib. How can I do this?
|
|
|
|
|
Go to Project > Properties in the main window, then in the dialog that pops up, Configuration Properties > Linker > Input. Type the library name into the Additional Dependencies box.
Regards,
--Perspx
"I've got my kids brainwashed: You don't use Google, and you don't use an iPod." - Steve Ballmer
"Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen an angry penguin charging at them in excess of 100mph." - Linus Torvalds
|
|
|
|
|
I have this class:
class CPROXY
{
public:
CPROXY(void);
~CPROXY(void);
int CreateConnector();
int CreateAcceptor(int nPort);
:
:
:
private:
ACE_SOCK_Acceptor client_acceptor;
ACE_SOCK_Connector server_connector;
std::list <spair*> queue;
}
Now the implementation is like this:
int CPROXY::ServerThreadRunner()
{
:
DWORD thid;
HANDLE hServerThread = CreateThread(NULL, 0, ServerThread, this, 0, &thid);
:
:
}
DWORD WINAPI CPROXY::ServerThread(LPVOID param)
{
CPROXY *newobj = (CPROXY *)param;
newobj->CreateConnector();
return 0;
}
int CPROXY::CreateConnector()
{
EnterCriticalSection(&guard);
SPAIR *sPair = queue.front();
queue.pop_front();
LeaveCriticalSection(&guard);
SetEvent(wait_server);
:
:
:
Take a look at queue. Queue is declared as a list of SPAIR. Do you think it is necessary for me to guard it with critical section every time is accessed by a thread?
I mean, before i run the thread i did put it into a newobj, so meaning that every newobj has its own member so no need for me to put critical section to guard it, right?
PLEASE, correct me if I'm wrong! i need to optimize this code.
|
|
|
|
|
auralius wrote: before i run the thread i did put it into a newobj, so meaning that every newobj has its own member
I'm not sure what you mean by that.
Your code doesn't show how many CPROXY objects are created.
Just because you do this:
CPROXY *newobj = (CPROXY *)param;
doesn't mean there's a new CPROXY object - it's just a pointer to an object
that is passed to the thread.
If every thread has its own CPROXY object, then no, you don't need synchronization.
If every thread is using the same CPROXY object, and there's any chance more than
one thread can access this object at the same time, then yes you need synchronization.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thank for your reply.
I mean there is a main function that will call int ServerThreadRunner(). Meaning that for every thread will be handled by new CPROXY newobj pointer.
So, if it is only pointer pointing the same location, does it mean that i need to put synchronization for every data member that accessed by the thread function?
How about this:
std::list <spair> queue;
vs
std::list <spair*> queue;
which one needs synchronization, and which one doesn't need?
What came to my mind is: there is no need for synchronization unless i put the queue as a static variable. am i right?
static std::list <spair*> queue;
sorry if my question is not really good. i hope you understand. i can't just solve that problem by trial & error because both of them work. I need strong concept.
|
|
|
|
|
auralius wrote: eaning that for every thread will be handled by new CPROXY newobj pointer.
Different pointers to CPROXY objects is not the same as different CPROXY objects.
All the threads will have their own pointers but they could all point to the same
object, in which case you'd need synchronization.
If there's a separate CPROXY object for every thread, then no synchronization is necessary.
auralius wrote: there is a main function that will call int ServerThreadRunner()
Can you show how you do that?
auralius wrote: What came to my mind is: there is no need for synchronization unless i put the queue as a static variable. am i right?
No. It all comes down to actual object instances. Multiple threads can access
a single object instance no matter how it's stored. If multiple threads can
change the same object, then that object should be protected with synchronization.
You haven't shown relevant code so it's hard to tell if you need it there or not.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|