开发者

User Defined Types Passing to a Function is a Call By Value in C?

开发者 https://www.devze.com 2023-01-24 22:39 出处:网络
I have a struct and I pass开发者_开发问答 this struct to function. Maybe function protype is: typedef struct

I have a struct and I pass开发者_开发问答 this struct to function. Maybe function protype is:

typedef struct
{
    //Bla Bla
} ABC;

void func(ABC abc)
{

}

This function calling is Call by value or Call by referance? Someone say that "C doesnt have Copy Constructor so we cant pass user defined types with value". Is this idea correct?


Call by value. C is always call by value.

(C doesn't have copy constructors but structures can still be copied by creating a second structure with the original structure as its initializer. Function parameters are initialized with the values that you pass as arguments; it's the same mechanism at work.)

0

精彩评论

暂无评论...
验证码 换一张
取 消