"Page" class, CGI Programming

This is a discussion on "Page" class, CGI Programming within the C++ Programming forums, part of the General Programming Boards category; Not a question, just thought I would share it. I've been using C for cgi programming for a while, I'm ...

  1. #1
    Registered User
    Join Date
    Jul 2011
    Location
    Godthåb, Grønland
    Posts
    9

    "Page" class, CGI Programming

    Not a question, just thought I would share it. I've been using C for cgi programming for a while, I'm just now getting a real grip on C++. Anyway, I'm working on a "page" class, with methods that make HTML items...

    I'm just starting out with this. I plan to add forms, tables, and maybe dynamic data...

    Code:
    #include <iostream>
    using namespace std;
    
    class Page{
            public:
                    Page();
                    ~Page();
                    void div(char *style, char *contents);
                    void pr(char* prdata);
                    void pgfoot();
            private:
                    int pgid;
    };
    
    Page::Page(){
            pgid=1;
            cout<<"Content-type: text/html\n\n";
            cout<<"<html>\n<head />\n<body>"<<endl;
    }
    
    Page::~Page(){
    }
    
    void Page::div(char *style, char *contents){
            cout << "<div style=\'"<<style<<"\'>" << endl;
            cout << contents << "</div>" << endl;
    }
    
    void Page::pr(char* prdata){
            cout << prdata<<endl;
    }
    
    void Page::pgfoot(){
            cout <<"</body>"<<endl;
            cout <<"</html>"<<endl;
    }
    
    int main(){
            Page pg;
            pg.div("color:#00cc99;background-color:#ccccff;","<p>It works!</p>");
            pg.pgfoot();
            return 0;
    }
    I'm thinking of making a few versions that support different DTD's when I'm done.

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,437
    char* ==> std::string.
    Make sure you don't use using directives in headers (it will pollute source files that include it).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 09-19-2011, 03:12 AM
  2. the operator "="error in class "String"
    By boyhailong in forum C++ Programming
    Replies: 9
    Last Post: 07-27-2011, 08:39 PM
  3. New board feature: automatically refreshing "New Posts" page?
    By Sebastiani in forum General Discussions
    Replies: 14
    Last Post: 10-12-2009, 10:04 PM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 07:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 06:59 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21