[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ns] Really need your help in creating new c++ classes



Hello Everyone:

I met some problems with creating new c++ classes and
I 
looked into the mail list but did not find good 
answers. I wrote the new class like this:

//Test.cc
#include <stdio.h>
#include <string.h>
#include "agent.h"

class MyAgent : public Agent {
public:
        MyAgent();
};

MyAgent::MyAgent() : Agent(PT_UDP) {
}

static class MyAgentClass : public TclClass {
public:
     MyAgentClass() : TclClass("Agent/MyAgentOtcl") {}
     TclObject* create(int, const char*const*) {
             return(new MyAgent());
     }
} class_my_agent;

I wrote my tcl script like the following:
//Test.tcl
set t0 [new Agent/MyAgentOtcl]

I added the Test.cc into the ns directory and modified
the Makefile and Makefile.in both by adding Test.o. 
I recompiled ns by make.

I run the tcl script and get the following error:

invalid command name "Agent/MyAgentOtcl"
    while executing
"Agent/MyAgentOtcl create _o3 "
    invoked from within
"catch "$className create $o $args" msg"
    (procedure "new" line 3)
    invoked from within
"new Agent/MyAgentOtcl"
    invoked from within
"set t0 [new Agent/MyAgentOtcl]
"
Any suggestion is warmly welcomed.
Thank you.
Dan.

__________________________________________________
Do You Yahoo!?
Buy the perfect holiday gifts at Yahoo! Shopping.
http://shopping.yahoo.com