GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rating: Thread Rating: 5 votes, 4.60 average.
  #1  
Old 29-May-2003, 22:08
admin's Avatar
admin admin is offline
Administrator
 
Join Date: Sep 2002
Posts: 1,049
admin will become famous soon enough

GIDForums enables New [C] / [C++] bbcode.


The GIDForums™ Team is proud to announce that GIDForums™ is now among one of the very first Webmaster forums to offer a custom-written C/C++ Syntax Highlighter BBCode ([C] bb code) to it's valued members and readers.

Please use the [C] and [/C] or [C++] and [/C++] tag pair to enclose any C or C++ code so that it appears like in the sample effect below: Please hit CTRL+F5 to reload the CSS if you don't see the colours.

Sample Effect of [C] BB Code Tag


CPP / C++ / C Code:
/* ---------------------------------------------------- */
/* This is a C-style comment, nothing particular to say */
/* but here we are.                                     */
/*                                                      */
/*                                                      */
/* -----------------------------------------------------*/

#include <iosfwd>
#include <list>
#include <map>
#include <string>

using namespace std;

using std::string;
using std::list;

#define ONE 1
#if defined(ONE)
#define TWO 2
#endif

typedef map<string, string> map_of_strings_t;

// -------------------------------------------------
// This is a C++ style comment.  Once again, nothing 
// particular to say but here we are!
// -------------------------------------------------

// a class declaration, typically found in .H files
class JustABaseClass
{

public: // public members

  int somePublicInt;
  string somePublicString;
  std::string somePublicStringWithScopeResolution;

  list<string> aListOfStrings;

  JustABaseClass(); // a constructor declaration
  virtual JustABaseClass(); // a destructor declaration

protected: // protected members


private: // private members

  // pure virtual declaration
  virtual int somePureVirtualMethod() = 0;

  // virtual declaration (expects implementation)
  virtual int someVirtualMethod(); 

  // const accessor declaration
  int getSomeInt() const; 

  // mutator declaration with value passed by const reference
  int setSomeString(const std::string &value); 

};

// Now for a bit of implementation, typically 
// found in .cpp or .cc or .cxx files.

JustABaseClass::JustABaseClass()
{
  // insert constructor code here...
}

JustABaseClass:~JustABaseClass()
{
  // insert destructor code here...
}

int JustABaseClass::getSomeInt()
{
  return somePublicInt;
}

int JustABaseClass::setSomeString(const std::string &value)
{
  somePublicString = value;
}

// And now for some more odd template stuff...

// a free template method

template <typename C>
int split(C &container, const std::string &data)
{
  // implement some code to parse data and add data 
  // elements to container ...
}

The use of this tag is still experimental at this stage and there is still a lot of work to do; please notify the moderators if something doesn't appear quite right as a result of using this bbcode tag in your post.
__________________
Custom BB codes you can use here:
[HTML] | [C++] | [CSS] | [JAVA] | [PY] | [VB]
  #2  
Old 31-May-2003, 01:37
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,370
JdS will become famous soon enough

COMMENTS testing...


This is a test post: (single line comments)

CPP / C++ / C Code:
//* comment this line only
int JustABaseClass::setSomeString(const std::string &value)
{
  somePublicString = value;
}
//*/

/* comment everything here
int JustABaseClass::setSomeString(const std::string &value)
{
  somePublicString = value;
}
//*/

///* comment this line only
int JustABaseClass::setSomeString(const std::string &value)
{
  somePublicString = value;
}
//*/
__________________
J de Silva

GIDApp | GIDBlog | GIDForums | GIDNetwork | Learning Journal
  #3  
Old 31-May-2003, 12:12
Garth Farley Garth Farley is offline
Awaiting Email Confirmation
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Very impressive J, let me see what I can try:

CPP / C++ / C Code:
// Hey emacs, this is a -*- C++ -*- file
#ifndef _STACK_H
#define _STACK_H

#include <stdexcept>
using namespace std;

template <typename T, int max> class Stack {
public:
    // C'Tor for empty stacks
    Stack() throw() {
        top = 0;
    }

    // Add t to the top of the stack
    void push(T t) {
        if(isfull())
            throw overflow_error("Stack overflow!");
        contents[top++] = t;
    }

    // Remove and return the top of the stack
    T pop(){
        if(isempty())
            throw underflow_error("Stack underflow!");
        return contents[--top];
    }
    
    // Will push() succeed?
    bool isfull(){
        return top>= max;
    }

    // Will pop() succeed?
    bool isempty(){
        return top==0;
    }
private:
    int top;
    T contents[max];
    
};

#endif


Lets see how a template goes.

GF
  #4  
Old 31-May-2003, 13:01
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about
this page looks funny on Konqueror.

tables are messed up
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #5  
Old 31-May-2003, 23:39
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,370
JdS will become famous soon enough
Does anyone have an opinion on the colours? I mean, should the keywords remain blue/bold or should it be purple and normal weight?

I personally think that the bolds are distracting but I am a C/C++ newbie, what do I know?

Allowee, would it possible for you to paste / link a screenshot? This is not a priority right now but I would certainly like to fix it eventually.
__________________
J de Silva

GIDApp | GIDBlog | GIDForums | GIDNetwork | Learning Journal
  #6  
Old 01-Jun-2003, 03:39
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about
here's the screenshot...

I hope you can see that everything is messed up, it's to big to fit on my screen..
Attached Images
File Type: jpeg snap6..jpeg (96.1 KB, 300 views)
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #7  
Old 03-Jun-2003, 06:20
Garth Farley Garth Farley is offline
Awaiting Email Confirmation
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Yeah, the tables have gone everywhere! And I've no idea why The source looks fine. Bug?

GF
  #8  
Old 06-Jun-2003, 15:59
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,370
JdS will become famous soon enough

Made some minor changes to the highlighted code boxes


I made some changes to all the highlighted boxes (CSS, C++ and HTML) and wonder if the tables are still messed up. I do not have Konqueror on my machine so I have to rely on your feedback as usual.
__________________
J de Silva

GIDApp | GIDBlog | GIDForums | GIDNetwork | Learning Journal
  #9  
Old 07-Jun-2003, 02:23
Allowee's Avatar
Allowee Allowee is offline
Regular Member
 
Join Date: May 2003
Location: The Netherlands
Posts: 339
Allowee has a spectacular aura about
it looks normal now on Konqueror

Thanks
__________________
Pastebin
PHP Documentation Site
Allowee's Blog http://allowee.net
  #10  
Old 07-Jun-2003, 02:28
jrobbio's Avatar
jrobbio jrobbio is offline
Regular Member
 
Join Date: Jan 2003
Location: Loughborough, England
Posts: 840
jrobbio will become famous soon enough
So the moral is don't use shortened code since it will work in one place and break something else in another.

Rob
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Php bbcode issue Caged MySQL / PHP Forum 3 06-Aug-2003 18:55
GIDForums enables New [KBD] bbcode. admin GIDForums™ 0 24-Jul-2003 06:26
GIDForums enables New [CSS] bbcode. admin GIDForums™ 0 01-Jun-2003 23:57
GIDForums enables New HTML BBCode. admin Web Design Forum 0 17-Feb-2003 16:52

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 11:31.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.