Click here to Skip to main content
12,068,141 members (48,779 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ Sockets
I have cut-and-paste the full difinition of "testlist" to the winsock2server.cpp, and also include" router.h" in the winsock2server.cpp( this is for router definition visible), but still does not work.
in my algorithm, the main.cpp file as:
#include <iostream>
#include <string>
using namespace std;
#include "router.h"

template <typename T>
void testList(Router < T > &listObject, const string &typeName)
{
    cout <<" Testing a list of " << typeName << " values \n";
	instructions ();
	int choice;
	T value;
	do
	{
      cout << "?";
	  cin >> choice;
 
	  switch (choice)
	  {
	  case 1:
		  cout << "enter" << typeName <<":";
		  cin >> value;
		  listObject.Register(value);
		  listObject.print();
		  break;
	  case 2:
	      cout << "enter" << typeName <<":";
		  cin >> value;
		  listObject.sendRegistration(value);
		  listObject.print();
		  break;	 
      case 3:
	      if (listObject.sendRegistrationCancellation(value))
			  cout << value <<" removed from list\n";
		  listObject.print();
		  break;	 
 
	  case 4:
	      if (listObject.sendCancellationConfirmation(value))
			  cout << value <<" removed from list\n";
		  listObject.print();
		  break;	 
        
	  }
	} while (choice != 5);
	cout << "End list test \n\n";
}
 

void instructions ()
{
	cout << "enter one of the following:\n"
		<< " 1 to register node to the list\n"
		<< " 2 to sendRegistration to the node \n"
		<<" 3 to sendRegistrationCancellation to the list\n"
		<<"4 to end list processing \n";
}
 
int main ()
{
 Router <int> integerRouter;
 testList ( integerRouter, "integer");
 Router < double> doubleRouter;
 testList ( doubleRouter, "double");
 return 0;
}
</int>

I want to call this algorithm in the server, so i put
Router <int> integerRouter;
testList ( integerRouter, "integer");
Router <double> doubleRouter;
testList ( doubleRouter, "double");
in the winsock2.server, to try to call,cannot implement sucessfully.
Posted 3-Oct-10 17:56pm
Edited 3-Oct-10 23:26pm
CPallini374.6K
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

As router's a template don't you get an error in main at:

Router integerRouter;

?

Cheers,

Ash
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160208.1 | Last Updated 4 Oct 2010
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100