Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

array/struct as arg in c++

Name: Anonymous 2012-08-07 14:09

Let's say you have something like:
int tmp=5;
f(tmp);

and it can be written shorter as:
f(5);
This works but what if the argument is an array or a struct?
Something like
f({1,2,3});
doesn't work. Is there an easier way than using a temporary variable?

Name: Anonymous 2012-08-07 14:11

Never mind, I am pants-on-head retarded. One second after creating this thread I realized I can use the typecast operator.

Name: Anonymous 2012-08-07 14:16

>>2
pants-on-head retarded
I'm adding this to my vernacular.

Name: Anonymous 2012-08-07 14:16

type·cast
verb \ˈtīp-ˌkast\
type·cast type·cast·ing
Definition of TYPECAST
transitive verb
1 to cast (an actor or actress) in a part calling for the same characteristics as those possessed by the performer
2 to cast (an actor or actress) repeatedly in the same type of role
3 stereotype

Name: -std=c++0x 2012-08-07 14:28


struct shit {
  int lisp;
  float haskell;
};

void foo(const shit& hurr) {
  printf("%x\n", hurr.lisp);
  printf("%f\n", hurr.haskell);
}

int main() {
  foo({0xDEAD, 0.0f});
  return 0;
}

Name: Anonymous 2012-08-07 17:03

>>5
C is undefined shit.

Name: Anonymous 2012-08-07 17:15

>>6 It's good that he didn't use it then.

Don't change these.
Name: Email:
Entire Thread Thread List