Alf P. Steinbach said:
* Gary Wessle:
You need a 'main' function, and you need to supply the argument to
'system' as a string, that is, in quotes, and a semicolon after the
command.
In short, you need a beginner's book.
Do you have one?
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
thanks
it would be good if I can give this complete example
first the error and the code.
ps: I have Thinking IN C++ second ed. vol1 and vol2 by Bruce Eckel,
as well as "The C++ Programming Language by Stroustrup"
I am going through the first now and doing my own self assigned
thing.
ok, here are the code
**************** the error ****************
fred@debian:~/myPrograms/common$ make
g++ -c -o read_data.o read_data.cpp
g++ read_data.o -o proj
/usr/lib/gcc/i486-linux-gnu/4.0.4/../../../../lib/crt1.o: In function `_start':
../sysdeps/i386/elf/start.S:115: undefined reference to `main'
collect2: ld returned 1 exit status
make: *** [proj] Error 1
****************************************************************
**************** the code in 4 files ****************
****************read_data.h ****************
#ifndef READ_DATA_H
#define READ_DATA_H
#include <string>
using std::string;
class read_data
{
int number_of_lines;
string file_name;
public:
read_data(string);
~read_data();
int get_number_of_lines();
};
#endif
**************** read_data.cpp ****************
#include <string>
#include <fstream>
#include <iostream>
#include "read_data.h"
#include <cstdlib>
using std::system;
read_data::read_data(string s) {
file_name = s;
}
int read_data::get_number_of_lines() {
number_of_lines = system ("wc -l file_name");
return number_of_lines;
}
**************** read_data_test.cpp ****************
#include <string>
#include "read_data.h"
using namespace std;
int main() {
string file_name = "../data/ZB/Jun06/20060405"; // or get it from the
// command line
read_data file1(file_name);
file1.get_number_of_lines;
}
**************** the makefile ****************
OBJS = read_data.o
COMP = g++
#### linker section ####
proj: $(OBJS)
$(COMP) $(OBJS) -o proj
########################
#### compiler section ####
.SUFFIXES:.o .cpp .h
.h.o:
$(COMP) -c $<
##########################