c++ - void() issue - It doesn't print results -


i writing program split in 3 different files:

  1. 1) header named my.h;
  2. a source cpp file named my.cpp;
  3. the main file named use.cpp;

here statements:

/* header file my.h define global variable foo , functions print , print_foo print results out */  extern int foo; void print_foo(); void print(int); 

/* source file my.cpp defined 2 funcionts print_foo() , print() , in called library std_lib_facilities.h */  #include "stdafx.h" #include "std_lib_facilities.h" #include "my.h"  void print_foo() {     cout << "the value of foo is: " << foo << endl;     return; }  void print(int i) {     cout << "the value of is: " << << endl;     return; } 

/ use.cpp : definisce il punto di ingresso dell'applicazione console. //  #include "stdafx.h" #include "my.h" #include <iostream>  using namespace std;   int _tmain(int argc, _tchar* argv[]) {     int foo = 7;     int& = foo;     = 99;     char cc = '0';      while (cin >> cc) {         switch (cc) {         case '1':             void print_foo();             break;         case '2':             void print();             break;         default:             exit(exit_failure);         }     }      return 0; } 

my main problem program compiles , run correctly doesn't print supposed.

how can fix it?

thank you!

leo

to call function specifying return type not required. correct

void print_foo();    // declares function prototype 

to

print_foo(); 

and

print(i);    // pass argument 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -