From: Eric <eric@cisu.net>
To: linux-c-programming@vger.kernel.org
Subject: Pointers to classes
Date: Sat, 19 Jun 2004 23:46:34 -0500 [thread overview]
Message-ID: <200406192346.34166.eric@cisu.net> (raw)
Hello
First I would like to say im fairly new to C++ and keep in mind you will
probably see many glaring mistakes in reading my code, please be kind. Hey,
thats how we learn :)
My problem is with pointers to classes. I am writing a VPN management program
and have a class Connection, which handles a connection ppp0, ppp1, etc, and
is closely tied with a class ConfigFile, which handles all the variables for
that connection obviously read from a file.
I need to have a pointer to an object ConfigFile inside the Connection class
so I can access variables and such associated with that connection that were
read from a file. However, I am getting very strange compile errors when
trying to define the pointer to a class. These are the errors. Below are the
relevant files and how they are included.
*/home/bot403/programming/projects/vpn_client/src/connection.h:28: error:
syntax error before `*' token
*/home/bot403/programming/projects/vpn_client/src/connection.h:31: error:
parse error before `*' token
*/home/bot403/programming/projects/vpn_client/src/connection.h:36: error:
syntax error before `*' token
Here are the relevant files. Please let me know if you need additional
information.
BTW, I don't consider making Connection a sublass of configfile a solution
becuase I am already teaching myself alot with this project and am happy with
simpleton solutions. Subclasses/Inheritance would require that I teach
myself way too much to accomplish way too little.
---------------------start connection.h
class Connection
{
private:
char ifName[ 5 ];
char pppdopts[256];
char sshopts[256];
char pidfile[256];
ConfigFile * config;
pid_t pid;
public:
Connection(ConfigFile * cFile );
void printName( void );
int start();
int stop();
~Connection();
ConfigFile * getConfig();
};
----------------------- end file
-----------------------start configfile.h
int readElement( char buffer[], char option[], char argument[] );
using namespace std;
class ConfigFile {
private:
ifstream configFile;
char configFileName[ 256 ];
//File variables
char pppdevice[ 8 ];
char vpnhost[ 256 ];
char logfile[ 256 ];
char *pppdopts;
//SSH Specific
char sshcipher[ 15 ];
char sshlogin[ 256 ];
char sshidentity[ 256 ];
char *sshopts;
char sshport[ 10 ];
//Misc
char delay[ 10 ];
char vpnpidfile[80];
//Connection Details
char *networks[5];
char *nameservers[2];
//End File Variables
public:
ConfigFile( char *Name );
~ConfigFile();
int readConfig();
void printConfig();
int writeConfig(char *Filename);
char *getsshopts(char buffer[]);
char *getpppdopts(char buffer[]);
char *getlogfile(char buffer[]);
char *getpidfile(char buffer[]);
//FIXME
//char *getnetworks();
//char *getnameservers();
};
-----------end of file
-----------top of connection.cpp
#include <iostream>
#include <fstream>
#include <unistd.h>
#include "configfile.h"
#include "connection.h"
#include "strings.h"
#include "config.h"
------snip---------
-----------------end file
----------------top of configfile.cpp
#include <iostream>
#include <fstream>
#include "configfile.h"
#include "strings.h"
-----snip------------
--------------end of file
next reply other threads:[~2004-06-20 4:46 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-06-20 4:46 Eric [this message]
2004-06-20 5:06 ` Pointers to classes John T. Williams
2004-06-20 5:18 ` John T. Williams
2004-06-20 12:49 ` LDB
2004-06-20 13:30 ` Eric
-- strict thread matches above, loose matches on Subject: below --
2004-06-21 14:55 Huber, George K RDECOM CERDEC STCD SRI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200406192346.34166.eric@cisu.net \
--to=eric@cisu.net \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.