LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-15-2003, 07:58 AM   #1
Xiangbuilder
Member
 
Registered: Apr 2003
Location: Shandong province China
Distribution: fedora core 1.0
Posts: 206

Rep: Reputation: 30
How to write multiple c++ files?


Here is my try:
Code:
//print_bin.h:
void print_bin ();
Code:
//print_bin.cpp:
#include<iostream>
using namespace std;
void print_bin () {
         cout<<"abc";
}
Code:
//bitwise.cpp
#include "print_bin.h"
#include <iostream>
using namespace std;
int main () 
{
   int i;
}
[root@localhost fifth]# g++ bitwise.cpp print_bin.cpp -o bit_print
[root@localhost fifth]# ./bit_print
[root@localhost fifth]#
It can be compiled with no error, however, why the program don't output abc that is I want to do?
Thank you.
 
Old 09-15-2003, 08:53 AM   #2
SaTaN
Member
 
Registered: Aug 2003
Location: Suprisingly in Heaven
Posts: 223

Rep: Reputation: 33
You have to call the function print_bin() in the main() of your program
Code:
#include"print_bin.h"
#include<iostream>
using namespace std
int main()
{
int i;
print_bin();
}
When you include a file that you have made all the functions in that file accessible and not that you are calling them.
 
Old 09-15-2003, 09:12 AM   #3
Xiangbuilder
Member
 
Registered: Apr 2003
Location: Shandong province China
Distribution: fedora core 1.0
Posts: 206

Original Poster
Rep: Reputation: 30
Thank you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to write multiple threads working simultaneously ? indian Programming 3 09-19-2011 11:41 PM
multiple process write to a file tangxf Linux - General 2 11-23-2005 12:44 AM
Able to write files to MP3 player but no files written into actual device? olnex Linux - Hardware 0 11-11-2005 06:32 AM
using dd comand to write to multiple destinations dln2k5 Linux - Newbie 1 10-28-2004 05:17 PM
Help I need help tarring multiple files in multiple directories VisionZ Linux - Newbie 28 03-25-2004 05:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration