|
You can have the plugin loaded without any "inside" code if you define the ctor as
CPlugin(const char* szDLLName, const char* szFunction){} and provide some GetPlugin accesor for later use. IMHO this is probably better than the Load scheme, since the only purpose of CPlugin is to make the loading anyway. Following this approach, you might want to move the unloading code to the dtor of the class and supress the explicit loading functions altogether. This fits nicely with a C++ idiom called RAII (Resource Acquisition is Initialization), which you can google for for further info.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for the sugguestion. I will look into it.
Steve
|
|
|
|
|
Ok, I just put:
PLUGIN.Load("HTPCPlugin.dll", "GetPlugin");
inside of a function and it compiled beautifully.
I am new to templates so what is going on here?
Steve
|
|
|
|
|
There is surely something I do not understand here. I would very much appreciate if someone could explain to me how I screwed this up.
Thank you.
--------------------Configuration: TCPIPwatch - Win32 Debug--------------------
Compiling...
TCPIPwatchDlg.cpp
C:\DOCUMENTS AND SETTINGS\ADMIN\DESKTOP\SSPROJECT\TCPIPwatch\TCPIPwatchDlg.cpp(235) : error C2664: 'bind' : cannot convert parameter 2 from 'struct CTCPIPwatchDlg::TCPIPWConnectSock::SOCKADDR_IN *' to 'const struct sockaddr *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
TCPIPwatch.exe - 1 error(s), 0 warning(s)
void CTCPIPwatchDlg::TCPIPWConnectSock(SOCKADDR_IN *dest, SOCKET &theTrgSock)
{
dest->sin_family = AF_INET;
dest->sin_port = 80;
if(dest->sin_port == INVALID_SOCKET)
AfxMessageBox("Port is invalid.",MB_OK);
theTrgSock = socket(AF_INET, SOCK_RAW, IPPROTO_IP);
const char RCVTIMEO[50] = "5000";
setsockopt(theTrgSock, SOL_SOCKET, SO_RCVTIMEO, (RCVTIMEO), 4);
bind(theTrgSock, (struct SOCKADDR_IN*) dest, sizeof(dest));
}
|
|
|
|
|
Hi,
typecast with (const ::SOCKADDR*) to 2nd parameter for function bind().
Cheers
The chosen One
|
|
|
|
|
Well, I am comming along more and more with this program, but I could still obviously use some help. I am going to put the specifications in full out here.
Define a class for triagnles. A triangle is defined by three sides. Class should have following capabilities:
A constructor that will allow definining a triangle. (float side1, float side2, float side3). The constructor is to call Order to place the sides in order from smallest to largest.
A constructo with no arguments: initialize the three sides to zero.
Public member functions needed.
void SetTriangle(float side1, float side2, float side3);
bool IsEquilateral();
bool IsIsosceles();
bool IsScalene();
bool IsRight();
bool IsAcute();
bool IsObtuse();
friend Triangle Copy(Triangle triangle1);
friend bool operator ==(const Triangle& triangle1, const Triangle& triangle2);
friend ostream& operator <<(ostream& outs, Triangle& the_triangle);
Private member functions needed.
void Order;
void Swap;
I need to write a program that will define triangle1, triangle2, triangle3, triangle4
am to define a class for triangles, and once I have defined it I need to do tese procedurse:
The constructor (with sides) is to call order to order the sides from smallest to largest.
and
The SetTriangle function is to call order to order the sides from smallest to largest
and then display the sides and the type it is... scalene and right, isosceles and acute, ....
I think I may need to give more detail. Triangle1 will not have any values defined. Triangle2 has sides 6.0, 6.0, 6.0. Triangle3: 5.0, 4.0, 3.0. Triangle4: 6.0, 4.0, 4.0
And then for Triangles 2, 4, and 4... I
1) Use friend operator function << to display the three sides of each
2) Test to see if the triangle is Equilateral, Isosceles, or Scalene. When one of the functions returns true, display message. Message should not be displayed within function.
3) Test to see if Right, Acute, Obtuse
For the copy test
1) Use the friend copy function to copy triangle 4 to triangle 1
2) Use friend operator function << to display the three sides of triangle 4 and triangle 1.
3)Use friend operator function == to see if triangle 1 is equal to triangle 4. If the two are, display " are equal", otherwise " are not equal.
For another == test, do the following
1)Use friend operator function << to display three sides of triangle2 and triangle3.
2)Use friend operator function ++ to see if triangle2 is equal to triangle3 and display appropriate message
For the SetTriangle test, do the following:
1)set Triangle3's sides to (5, 4, 3 (in that order))
2)use friend operator function << to disply the three sides of triangle3.
There are all the specifications and what not. It has been like a week... and I have only gotten as far as this Could I please get some help all around on this one. I would so much appreciate it. Please, could I get some help. I have done this much on my own, and now I have just gotten stuck and don't really have a clue as what to do.
My code is
#include <iostream.h><br />
#include <stdlib.h><br />
<br />
class Triangle<br />
{<br />
public:<br />
friend Triangle Copy(Triangle triangle1);<br />
friend bool operator ==(const Triangle& triangle1, const Triangle& triangle2);<br />
friend ostream& operator <<(ostream& outs, Triangle& the_triangle);<br />
<br />
Triangle(float side1, float side2, float side3);<br />
Triangle();<br />
<br />
void SetTriangle(float side1, float side2, float side3);<br />
<br />
bool IsEquilateral();<br />
bool IsIsosceles();<br />
bool IsObtuse();<br />
<br />
float get_side1();<br />
float get_side2();<br />
float get_side3();<br />
<br />
private:<br />
void order(float side_1, float side_2, float side_3);<br />
void swap(float side_1, float side_2);<br />
<br />
float side_1, side_2, side_3;<br />
};<br />
<br />
void main()<br />
{<br />
Triangle triangle1, triangle2(5.0, 4.0, 3.0), triangle3(6.0, 4.0, 4.0);<br />
cout << "Display triangle 1:\n";<br />
cout << "Side 1 = " << triangle1.get_side1() << endl;<br />
cout << "Side 2 = " << triangle1.get_side2() << endl;<br />
cout << "Side 3 = " << triangle1.get_side3() << endl;<br />
<br />
cout << "Display triangle 2:\n";<br />
cout << "Side 1 = " << triangle2.get_side1() << endl;<br />
cout << "Side 2 = " << triangle2.get_side2() << endl;<br />
cout << "Side 3 = " << triangle2.get_side3() << endl;<br />
<br />
cout << "Display triangle 3:\n";<br />
cout << "Side 1 = " << triangle3.get_side1() << endl;<br />
cout << "Side 2 = " << triangle3.get_side2() << endl;<br />
cout << "Side 3 = " << triangle3.get_side3() << endl;<br />
<br />
}<br />
<br />
<br />
Triangle Copy(Triangle triangle1)<br />
{<br />
Triangle copy;<br />
<br />
copy.order = triangle1;<br />
return copy;<br />
}<br />
Triangle::Triangle(float side1, float side2, float side3)<br />
{<br />
side_1 = side1;<br />
side_2 = side2;<br />
side_3 = side3;<br />
} <br />
<br />
void swap(float side_1, float side_2)<br />
{<br />
float temp;<br />
temp = side_1;<br />
side_1 = side_2;<br />
side_2 = temp;<br />
}<br />
<br />
void order(float side_1, float side_2, float side_3)<br />
{<br />
if (side_1 > side_2)<br />
swap (side_1, side_2);<br />
if (side_1 > side_3)<br />
swap (side_1, side_3);<br />
if (side_2 > side_3)<br />
swap (side_2, side_3);<br />
}<br />
<br />
<br />
<br />
Triangle::Triangle() : side_1(0), side_2(0), side_3(0)<br />
{<br />
}<br />
float Triangle::get_side1()<br />
{<br />
return side_1;<br />
}<br />
float Triangle::get_side2()<br />
{<br />
return side_2;<br />
}<br />
float Triangle::get_side3()<br />
{<br />
return side_3;<br />
}
|
|
|
|
|
OK, let me see, if i understood you correctly.
You want to use an overloaded operator << . But what you have done, is only using the normal output of an float.
The overloading would look like this:
ostream& operator<< (ostream& ostr, CTriangle& triangle)
{
ostr << "Side1 = " << triangle.side1 << endl
<< "Side2 = " << triangle.side2 << endl
<< "Side3 = " << triangle.side3 << endl;
return ostr;
}
The overloaded operator== looks like this:
bool operator ==(const CTriangle& tri1, const CTriangle& tri2)
{
if (tri1.side1 == tri2.side1
&& tri1.side2 == tri2.side2
&& tri1.side3 == tri2.side3)
return true;
else
return false;
}
My personal advice:
You should divide your program into three files.
-----------------------
First file -
a file containing the declaration of the triangle class. Name this file triangle.h
!! Remember that triangle is a class, so name the class CTriangle. !!
-----------------------
Second file -
Name this file triangle.cpp
include your triangle.h by using
#include "triangle.h"
Now put all the definitions of your CTriangle class in here (for instance yout get-functions etc. and the overloaded operators). Don't forget neccessary inclusions like iostream.h
-----------------------
Third file -
name this file main.cpp
include your triangle.h by using
#include "triangle.h"
#include <iostream.h>
void main()
{
CTriangle triangle1, triangle2(5.0, 4.0, 3.0), triangle3(6.0, 4.0, 4.0);
cout << "Display triangle 1:\n";
cout << triangle1 ;
cout << "Display triangle 2:\n";
cout << triangle2 ;
cout << "Display triangle 3:\n";
cout << triangle3;
if (triangle2 == triangle3)
cout << "identical" << endl;
else
cout << "not identical" << endl;
<
}
I havent compiled it, but this should work. Test it by changing the values of the triangle2 and triangle3.
Hope this helps
sledge
|
|
|
|
|
ÓÃÖÐÎĶàºÃ£¬Ó¢ÎÄ¿´²»¶®£¡;P
|
|
|
|
|
Yeah....that's probably not going to compile.
When I can talk about 64 bit processors and attract girls with my computer not my car, I'll come out of the closet. Until that time...I'm like "What's the ENTER key?"
-Hockey on being a geek
|
|
|
|
|
heres my problem
float r=10.3;
int x=10;
int z=ceil(r*x) gives me 104 . I need 103
I need output to be converted as
if product = 103.1 o/p = 104
if product = 103.0 o/p=104
if product = 103.5 o/p = 104
Basically i dont want it to take the upper no if the product can be equivalently represented by an integer
what i mean is 103.0 is actually 103
but 103.1 isnt 103
|
|
|
|
|
Hi
double r=10.3;
int x=10;
int z= ::ceil(r*x);
will give 103
Chill
The chosen One
|
|
|
|
|
<code>float x = 3.01; x = ((int)x< ceil (x) )?(int)x:(int)x+1; </code>
a rough try
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
It's most likely round off error.
internally it figures that it is 103.0000000000001 and so it rounds up to 104. Look into the IEEE format used to store floats to figure out why.
J.
----------------------------
|
|
|
|
|
hi all,
i have an XML file..where i have some data as
<keywords>
<keyword>.net
<keyword>0% credit card
<keyword>0% interest credit card
<keyword>1 800 contacts
<keyword>1 800 flower
<keyword>1-800 flower
<keyword>1-800-flowers
I want to perform a search over this XML file as if i have "1-800-flowers". I dont want it to go thru each element and then reach there..it is a slow process as it goes in loop for each keyword tag..is there any way where i can perform a fast search for the data i have..so that it is fast..i am using VC++ with MSXML..Please help me out..
Thanks a lot in advance..
regards,
Himanshu
|
|
|
|
|
net
0% credit card
0% interest credit card
1 800 contacts
1 800 flower
1-800 flower
1-800-flowers
all this is the data embedded between tags that have the same name
like
<MYTAG>1 800 blah 1 </MYTAG>
<MYTAG>1 800 blah 2 </MYTAG>
<MYTAG>1 800 blah 3 </MYTAG>
<MYTAG>1 800 blah 4</MYTAG>
Then I am afraid u ll have to go thru each node and find out . if the tags are unique u can do a "getElementsByTagName" defined by DOM .
Engineering is the effort !
|
|
|
|
|
hi,
post proper XML u r using to get soln or or look into XPath query language on MSDN.
The chosen One
|
|
|
|
|
You could use XPath (Xalan). Not sure how compatible it is with MSXML. I use Xerces to parse XML.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Here is a sentence:
using namespace std
Could you tell me what is its meaning?
|
|
|
|
|
Hi,
"using namespace std;" means in ur program u r using namespace called as "std" provided by microsoft. all STL functionality u will get under this namespace.
Why we use namespaces? To avoid name collision.
Compiler tries to interpret objects or function calls user namespace if specified else searches in global namespace by default.
More info is given in MSDN.
The chosen One
|
|
|
|
|
Oh,I see
Thank you
In fact, I haven't found the result from MSDN as to using namespace std
Thank you again
|
|
|
|
|
shalala wrote:
In fact, I haven't found the result from MSDN as to using namespace std
Try here:
http://msdn.microsoft.com/library/en-us/vclang98/html/_pluslang_using_declaration.asp?frame=true
http://msdn.microsoft.com/library/en-us/vclang98/html/_pluslang_using_directive.asp?frame=true
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
|
These three ways can work well for multi-Threaded design.
They must be some differnt in some aspects although They look very alike.
Could you tell me the differnt between them, please!
Thanks in advance!
|
|
|
|
|
Hi,
type "synchronization [Win32]" in MSDN u will get it what u want.
The chosen One
|
|
|
|
|
Mutexes and Critical Sections are logically the same, but critical sections are cheaper/faster in exchange for only working within the same process.
Semaphores are counters, they have a value that can be incremented and decremented.
--
-Blake (com/bcdev/blake)
|
|
|
|
|