in my project, I have following 3 files
//t.h
#include
template
myFunc (std::vector& var){
....
}
//a.cpp
#include "t.h"
void funcA(){
std::vector a;
std::vector b;
myFunc(a);
myFunc(b);
}
void funcB();
int main(){
funcA();
funcB();
}
//b.cpp
#include "t.h"
void funcB(){
std::vector a;
std::vector b;
myFunc(a);
myFunc(b);
}
if I build it, I'll get an error that myFunc(std::vector&) defined
twice.
if I manage them in di
请大家看看为什么编译通不过,谢谢. 始终说最后的函数地址不match定义 。
牛人看看。
//header file
class Function_pointer
{
public:
int next(int n);
int before( int n);
int next_after_next( int n);
typedef int (*f)(int n);
void update( int n, f pointer );
};
// .cpp file
# include
# include"Header.h"
using namespace std;
int Function_pointer::next(int n)
{
return n +1;
}
int Function_pointer::before( int n)
{
return n - 1;
}
int Function_pointer::next_after_next( int n)
{
return n + 1 + 1;
}
void Function_pointer::up... 阅读全帖
不知道你想说啥。。。
C++ static 成员函数指针和非成员函数指针2者类型是不同的
class Function_pointer
{
public:
static int current(int);
int next(int n);
};
//static成员函数指针的类型是和c相同的所以不用instance就能直接调用
typedef int (*sf)(int n);
sf stcFunc= &Function_pointer::current;
cout<
//非static成员函数指针的类型则要求用instance才能调用
typedef int (Function_pointer::*f)(int n);
f fp1=&Function_pointer::next;
Function_pointer myFunc;
(myFunc.*fp1)(10);
这和cast,和引用没有任何关系
typedef int (*sf)(int n);
sf fps = &myFunc.next;
fps(111);
error: ISO C++ forbids taking the address of a bound member function to form
a pointer to member function. Say ‘&Function_pointer::next’
error: cannot convert ‘int (Function_pointer::*)(int)’ to ‘int (*)(int)’
in initialization
typedef int (*sf)(int n);
sf fps = (sf)&myFunc.next;
fps(111);
error: ISO C++ forbids taking the address of a bound member function to form
a pointer to member function. Say ‘&Function_pointer::next’
warning: co... 阅读全帖
【 以下文字转载自 Statistics 讨论区 】
发信人: light009 (light009), 信区: Statistics
标 题: pass arguments by reference in R
发信站: BBS 未名空间站 (Fri Apr 11 14:19:03 2014, 美东)
I need to do pass by reference in R by R studio on win 7.
My code:
myfunc<-function(myhash.arg, b)
{
myhash <- myhash.arg
if (!has.key("first", myhash))
myhash["first"] <- list()
alist <- myhash["first"]
alist <- append(alist, i)
eval.parent(substitute(myhash.arg<-myhash))
return(0)
}
ahash<-hash()
for(i in 1:5)
{
myfunc(myhash... 阅读全帖
为不同的浏览器,你可能得做不同的设置,例如我用下面这个 function
来获取该id代表的不同object
function getObj(id)
{
if (document.all) {
//IE
return eval('document.all.' + id);
} else if (document.getElementById) {
//for DOM supported browser
return
hehe, not related to compilor ba.
when a.cpp is compiled, myFunc(vector) is generated in a.obj
when b.cpp is compiled, myFunc(vector) is generated in b.obj
when these two obj get linked, same function definition colided.
Hello,请高手指点:
I am using Matlab integral function. I need to integrate a function of one
variable t for different values of a parameter y. The output is a vector for
each value of the parameter y.
for example:
function f = myfunc(x, a)
b = 0.5;
f = a+quad(@myInt, 0, 0.5*pi, [], b, x);
function v = myInt(t,b,x)
v = cos(t*b).*x;
%main.m
a = 4;
x = [ 1,2,3];
f = myfunc(x,a);
I got error message says:
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> myInt at 2
v = cos(t*b).
Yeah, my example was confusing. I could have written something like
\usepackage{amsmath}
\DeclareMathOperator{\myfunc}{myfunc} % no super- or subscript limits
\DeclareMathOperator*{\mylim}{mylim} % will have limits
Hello,请高手指点:
I am using Matlab integral function. I need to integrate a function of one
variable t for different values of a parameter y. The output is a vector for
each value of the parameter y.
for example:
function f = myfunc(x, a)
b = 0.5;
f = a+quad(@myInt, 0, 0.5*pi, [], b, x);
function v = myInt(t,b,x)
v = cos(t*b).*x;
%main.m
a = 4;
x = [ 1,2,3];
f = myfunc(x,a);
I got error message says:
??? Error using ==> mtimes
Inner matrix dimensions must agree.
Error in ==> myInt at 2
v = cos(t*b).
【 以下文字转载自 Statistics 讨论区 】
发信人: light009 (light009), 信区: Statistics
标 题: pass arguments by reference in R
发信站: BBS 未名空间站 (Fri Apr 11 14:19:03 2014, 美东)
I need to do pass by reference in R by R studio on win 7.
My code:
myfunc<-function(myhash.arg, b)
{
myhash <- myhash.arg
if (!has.key("first", myhash))
myhash["first"] <- list()
alist <- myhash["first"]
alist <- append(alist, i)
eval.parent(substitute(myhash.arg<-myhash))
return(0)
}
ahash<-hash()
for(i in 1:5)
{
myfunc(myhash... 阅读全帖
【 以下文字转载自 Statistics 讨论区 】
发信人: light009 (light009), 信区: Statistics
标 题: pass arguments by reference in R
发信站: BBS 未名空间站 (Fri Apr 11 14:19:03 2014, 美东)
I need to do pass by reference in R by R studio on win 7.
My code:
myfunc<-function(myhash.arg, b)
{
myhash <- myhash.arg
if (!has.key("first", myhash))
myhash["first"] <- list()
alist <- myhash["first"]
alist <- append(alist, i)
eval.parent(substitute(myhash.arg<-myhash))
return(0)
}
ahash<-hash()
for(i in 1:5)
{
myfunc(myhash... 阅读全帖
I need to do pass by reference in R by R studio on win 7.
My code:
myfunc<-function(myhash.arg, b)
{
myhash <- myhash.arg
if (!has.key("first", myhash))
myhash["first"] <- list()
alist <- myhash["first"]
alist <- append(alist, i)
eval.parent(substitute(myhash.arg<-myhash))
return(0)
}
ahash<-hash()
for(i in 1:5)
{
myfunc(myhash.arg = ahash, b = i)
print(c("length of ahash is ", length(ahash)))
print(c("length of ahash list is ", length(ahash["first"])))
}
but, the list size... 阅读全帖
Anyone knows how to call javascript function from applet in Opera?
In IE, it is as simple as
getAppletContext().showDocument (new URL("javascript:myFunc ()"));
but it does not work in Opera.
thx
Is there a way that we could invoke a function dynamically?
For example, at some point of the program, I need to call a function, but
the function name, input parameters need to be dynamic, which will be define
in a config file, loaded when the program start. The function always
return a integer.
the config file like this:
检测高手的时候到了
how to convert my c code into python ?
struct Header{
int f1;
int f2;
};
struct Data{
long f3;
unsigned short f4;
...
};
struct Info{
struct Header myHeader;
struct Data mhData;
};
struct Info myInfo;
// initialization here
myFunc(&myInfo, 1, 2, 3);
Header = [('f1', 'i4'),('f2', 'i4')]
Data = [('f3', 'i8'),('f4','u4'),...]
Info = [('myHeader',Header), ('mhData',Data)]
myinfo = np.array(((0,0), (0,0)), dtype=Info)
myfunc(myinfo, 1, 2, 3)
另 in python don't use camel case name for variables and functions, that's
quite ugly.