What are the most F.A.Q. on this forum?

Pages: 12345
@Duoas
I'm not sure exactly how much of a point there was to adding CSS data, since it will likely will find itself unused on this website. Nonetheless, this was nicely done. Congrats.

For your "will my compiler support C+11" subsection, please bear in mind that you will have a *lot* of work to do there. Your example will need to use lamba functions, auto, the new return type syntax, the new constant string syntax, rvalue references, final, override, variadic templates, range-based for loops... the list goes on and on. Unless, of course, you just check the value of the __cplusplus macro and trust that the developers were honest. >_>


@Grey Wolf
Is anyone else willing/got the time to help put some meat on the bones so to speak?
I am too.


-Albatross
Last edited on
I'll see if I can flesh out the sections by Monday (see my first post on page 1 for details). Any suggestions are welcome.

If you have something you would like to write, please do, and post/PM me/email me, as per my last post.

@Albatross
Yay! I'd love to have your input!

I used CSS since I could just write simple stuff without worrying too much about how the markup appears -- that way twicker can have an easier time migrating whatever we do to the site, and still look somewhat nice and/or like the site...

The C++11 section scares me, since I know next to nothing about C++11. I think that part of the issue will be that, since it is so new, many compilers will support a large subset of the new standard, but still have issues here and there. So I'd like to see something similar to the C++03 section, which allows you to compile something simple and also have something that pushes the boundries a little.
Alright, I have started adding information to the new FAQ section.
http://www.cplusplus.com/faq/

Please take time to review it and check me for accuracy.

Remember also, if you want to write-up a FAQ answer, send it to me via PM and I'll add it in.
Very nice, so far.
Well, it is the weekend and I would like some review. (Please!)

The entire "introduction" page http://cplusplus.com/faq/intro/
In particular, I cannot find an old compiler to test against http://cplusplus.com/faq/intro/#supports-pts and http://cplusplus.com/faq/intro/#supports-ptfo

Also, could I get a careful review of:
  Split a string         http://cplusplus.com/faq/sequences/strings/split/
  Parse XML data         http://cplusplus.com/faq/sequences/strings/xml/
  C-strings and pointers http://cplusplus.com/faq/sequences/strings/c-strings-and-pointers/
  strtok()               http://cplusplus.com/faq/sequences/strings/strtok/
  Trim a string          http://cplusplus.com/faq/sequences/strings/trim/
  Switch on a string     http://cplusplus.com/faq/sequences/strings/switch-on-string/

Also:
  strupper(), strlower() http://cplusplus.com/faq/sequences/strings/case-conversion/
particularly as my PC is dead at the moment and I'm using my kid's to do this... and I cannot get Boost's Locale Library to work on it. Could someone test that top code fragment? (And, if necessary, fix it?)

Even if you only look at one, please give me feedback!


I am also still looking for feedback at presentation. I am still messing around with it, so not everything is in its final place, but your thoughts are welcome.

Thank you!
Parse XML data
Why not have a comparison chart and/or a few code examples for each of the libraries? I think that would help people with picking out one of them.

C-strings and pointers
Don't wchar_ts and std::wstrings at least deserve a reference?

Switch on a string
I noticed you have no equivalent C example for this part. Also, the C++ code seems a bit... verbose.

Otherwise, really good work!

-Albatross
Last edited on
Ooo, ooo. Do we have one on

Why does if (x == 7 || 8)always come out as true?
Last edited on
Haha, that's a cute one --^
I'll need to ask some people in my class just to bug them.
faq wrote:
This is the C designed and published by the legendary Brian Kernighan and Dennis Ritchie, the inventors of Unix and C, respectively.

I don't think it's accurate to say Brian Kernighan invented UNIX since it was originally Ken Thompson's idea; it'd be more accurate to say he was a contributor.

In the section about OOP you could also mention that in OOP, classes tend to represent real-world objects or concepts. You could also explain that objects can be divided into state and behaviour - a speaker, for example, has the states "on" and "off" as well as one for the volume, while its behaviours would be "turn on", "turn off" and "change volume". In code form:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * Describes a speaker.
 */
class Speaker {
private:
	bool		TurnedOn;	/* Whether the speaker is on or off */
	unsigned	Volume;		/* The current volume. */
public:
	/**
	 * Gets the current on/off state.
	 */
	bool IsTurnedOn()
	{
		return this->TurnedOn;
	}

	/**
	 * Sets the current on/off state to "on".
	 */
	void TurnOn()
	{
		this->TurnedOn = true;
	}

	/**
	 * Sets the current on/off state to "off".
	 */
	void TurnOff()
	{
		this->TurnedOff = false;
	}

	/**
	 * Gets the current volume.
	 */
	unsigned Getvolume()
	{
		return this->Volume;
	}

	/**
	 * Sets the current volume.
	 */
	void SetVolume(unsigned value)
	{
		this->Volume = value;
	}
};

I found a similar explanation to this (in the Java tutorials) extremely helpful for understanding OOP.

[edit]
On the faq index page instead of saying "it is not comprehensive" it should say "it is not exhaustive", since "not comprehensive" makes it sound less useful.
Last edited on
I had no idea Kernighan was really involved with Unix. As far as I knew, it was primarily Ken Thompsons idea and he had Ritchie help. He needed C for Unix, and who better to have help with C than the creator himself??
@Albatross

XML
The comparison chart would be nice, but as I have personally never used any of them, I know nothing more than that they exist and some other minor information that is listed.

All the libraries I listed are capable of handling the complete XML specification; however the heavyweight ones do validation etc. I'll have to add this information to the FAQ.

C-strings and pointers
I didn't think so. Why?

Switch on a string
I didn't mean to put that in the list above. I haven't finished with it yet -- sometimes a FAQ just flows out, sometimes you have to plan carefully, and sometimes you do both and get nonsense that needs serious reworking... Alas.

@Moschops
Nice one. It is now #83. (I'll update the list on the first page shortly.)

@chrisname

K&R
Ack! Shows how much I remember! I'll fix that promptly!

OOP
I like that. I'll update it to have that explanation in there.

"comprehensive"
I was struggling for the appropriate word to use there. Thanks!
Last edited on
Okay, maybe not in that section, but seeing as UTF-16 is used quite a lot by a couple of notable libraries (example: Qt) to support characters that you don't see often on an American keyboard, I thought it'd be a good idea to mention it.

-Albatross
hello_world.
About the intro:
The imperative description seems to fit more to sequential paradigm
IIRC imperative is opposed to declarative programming,

[rant]
I don't like the inheritance example.
First because I don't know who Granny Smith is, and second those may be better represented as apple instances. (being the colour a property instead of a virtual method)

Regarding chrisname's example, please don't.
I would prefer something like 'Mario has lifes, and he can run, jump, and fire fire' instead of useless getters and setters.
[/rant]

Edit: the case conversion was throwing an std::bad_cast exception
fixed with http://www.boost.org/doc/libs/1_48_0/libs/locale/doc/html/faq.html
Last edited on
When I get more time I'll do a thurough review. I just glanced over the Split a string section and have 2 quick comments:

1) Under the iostream section, was tokenizing using the stream extraction operator demonstrated? In specific cases this can be quick and easy. It can also be combined with copy and back_inserter.

2) The table at the top is pretty cool. Could it also mention the standard (if any) that the approach is included in?
@Albatross
Having thought about it, I think that you are right that it is a good idea to at least mention wide strings in the C-strings and pointers section, but to go into detail elsewhere.

@ne555
The imperative is sequential. Since the development of the declarative paradigm its definition has been modified a bit, but essentially it is "do this, then that, then this, and if here then there".

About the apples: if you have a better example I will use it. (Fruit and animals are always the first stupid thing to be presented.) A Red Delicious and a Granny Smith are not just instances of an apple, they are distinct classes. An apple has a color, but the color is part of the type of apple. (A 'property' is not orthogonal to virtual methods, and is in fact quite often used together.)

Let me be more specific about my response to chrisname's example. I like the simple explanation that an object combines state and behavior. I didn't plan on incorporating any specific example... Should I?

Thanks for the link on the Boost Locale stuff. The example does not explicitly initialize any locale. I'll have to add a locale generator in there...

@moorecm
1) No. I didn't think of that one. I'll have to add it. (Do you have any particular example in mind?)

2) The table at the top is already getting pretty wide. What do you mean by "standard"? Outside of the pure C or C++ techniques, each approach applies to a specific library, but all approaches work with standard C or C++ compilers.

Thank you all for your valuable feedback!
No specific example, but I guess it'd be along the lines of a space delimited file of integers:
10 20 30

Doing a while( fin >> i ). It's a quick and dirty way to grab them when error checking isn't critical.

Perhaps have a cool example like the following (untested):
1
2
3
fstream fin( "data.txt" );
vector< int > v;
copy( istream_iterator< int >( fin ), istream_iterator< int >(), back_inserter( v ) );


Regarding the standard, I just meant at what standard, if any, are the functions included. For example, the Boost approaches require Boost. Iostream-based approaches are part of C++03. And so on. It's another piece of information to help answer the "which one should I use" question that is inherent in listing numerous approaches to accomplish tokenization.



I'm about to take a better look at the articles. I'll post back with comments later this afternoon--unless I get distracted by other priorities.

Last edited on
Ah, I think I understand what you are saying.

I had thought it would be fairly obvious from the table, that and some of the comments I made in each section; but I think you have a very good point.

I was also considering a FAQ subsection on getting certain things installed -- Boost in particular. And perhaps the MinGW and MSYS suite (since it is not obvious how to do it from the MinGW website -- not even in the How To part of their site).
Let me know if you need anything tested with any of:

g++ (GCC) 4.1.1
g++ (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
clang version 2.9 (tags/RELEASE_29/final)

I'm not planning on actually testing the snippets.
Comments from the Intro - XML:

Search the Introduction to C++ page for the following typo: "As for for C"

Regarding the Parse XML data article, I think it would be beneficial to explain a little about parser generators. For example, Yacc or BNU Bison, Boost.Spirit, etc. can be leveraged to parse XML.

There's even an example (using Boost.Spirit) here:
http://boost-spirit.com/repository/applications/show_contents.php
Comments from C-strings and pointers - :

Search the C-strings and pointers page for the following sentence. It appears to be missing "there" at the end: "If you have been directed here, please hang in."

In the memory subsection, is this a good place to mention the stack vs. the free store?

Early in the pointer subsection, is this a good place to describe pointer arithmetic? For example, incrementing a char * advances the pointer 1 sizeof(char).

Also, is it worth noting that std::string can contain null characters?

In the string literal subsection, should it specify where string literals are put in memory (or however they are handled by the compiler)?

In the Trim a string page, the examples are all functions definitions. Should there be a little example that uses each?

In the Switch on a string page, it doesn't mention why someone would want to do this. I think the rational should be up front and slap you in the face with elegance!

I also found this: "If not, you&srquo;ll need to convert"
Here: http://cplusplus.com/faq/sequences/strings/ci-compare/


All done. I lived up to my promise today. :P
Last edited on
Pages: 12345