comp.lang.c++
  Home FAQ Contact Sign in
comp.lang.c++ only
 
Advanced search
December 2007
motuwethfrsasuw
     12 48
3456789 49
10111213141516 50
17181920212223 51
24252627282930 52
31       1
2007
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
comp.lang.c++ Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  Re: counting words in input         


Author: arnuld
Date: Dec 16, 2007 23:55

> On Sun, 16 Dec 2007 12:00:59 -0500, Daniel T. wrote:
> Here is one of the solutions I came up with. Note especially how easy
> the "count_if" line is. "count_if... size_greater_than( 3 )" makes a lot
> of sense grammatically. Also note that I didn't make a separate
> 'make_plural' function. It is not that easy to pluralize a word so I
> tend to do it on a case-by-case basis.
>
> struct size_greater_than : unary_function< string, bool >
> {
> size_t x;
> size_greater_than( size_t x ): x( x ) { }
> bool operator()( const string& s ) const {
> return s.size() > x;
> }
> };

your solution is pretty simpler than my version but I did not understand
the very 1st function, the struct you created. What exactly it is doing ?

no comments
  copy a file to std output         


Author: arnuld
Date: Dec 16, 2007 22:19

I have 2 programs.

1st PROGRAM: copies an input file to standard output but it
does so at the expense of deleting all white-space
(space, tabs, newlinies etc).

2nd PROGRAM: copies the input as it is to the standard output.

WHAT I WANT:

I want to merge the 2 programs, I want to do what 2nd program does
by replacing "while loop" with "std::copy" as in 1st program.

any idea ?

int main( int argc, char** argv )
{
std::vector svec;
Show full article (1.33Kb)
2 Comments
  Re: C++ exception handling         


Author: babakandme
Date: Dec 16, 2007 15:34

Hi,
Take a look at:
"C++ How to Program, Fifth Edition" By Dietel & Dietel.
Chapter 16... Exception Handling.
no comments
  Re: counting words in input         


Author: Pete Becker
Date: Dec 16, 2007 08:48

On 2007-12-16 11:41:34 -0500, arnuld NoPain.com> said:
>
> it always outputs this:
>
> [arnuld@arch programs]$ ls
> 10.01.cpp 11.09.cpp 11.09.cpp~ 11.09_using-std-input.cpp a.out post.txt
> [arnuld@arch programs]$ ./a.out <10.01.cpp
> No input file ?
> [arnuld@arch programs]$ ./a.out < 10.01.cpp
> No input file ?
> [arnuld@arch programs]$ ./a.out
> No input file ?
> [arnuld@arch programs]$ cat 10.01.cpp | ./a.out
> No input file ?
> [arnuld@arch programs]$
Show full article (1.03Kb)
no comments
  Re: counting words in input         


Author: arnuld
Date: Dec 16, 2007 08:38

> On Sun, 16 Dec 2007 09:25:43 +0100, Alf P. Steinbach wrote:
> case default:
> {
> cerr << "Usage: plingplong [FILENAME]" << endl;
> return EXIT_FAILURE;
> }
> }

I am sure you left that "case" just before "default" to teach me a lesson.
Well, It took me 20 min to figure out the error from GCC and it really
taught me some lesson :)
no comments
  Re: ifstream/string ctor         


Author: James Kanze
Date: Dec 16, 2007 02:47

On Dec 16, 10:03 am, Chris Forone <4...@gmx.at> wrote:
> why have i to bracket the second ctor param in the following example?
> #include
> #include
> int main()
> {
> std::ifstream file(__FILE__);
>
> if (file.is_open())
> {
> noskipws(file);
> std::string text(std::istream_iterator(file),
> (std::istream_iterator())); // extra brackets here
> }
> }

You don't. You can bracket the first instead:-).
Show full article (1.20Kb)
1 Comment
  Re: return reference to local variable, good code?         


Author: Alf P. Steinbach
Date: Dec 15, 2007 22:09

* George2:
> Hello everyone,
>
>
> I am reading some code from other people, there are some code like
> this,
>
> [Code]
> class Foo {
>
> };
>
> Foo& func()
> {
> Foo foo;
> return foo;
> }
>
> int main()
> { ...
Show full article (1.10Kb)
no comments
  Re: return reference to local variable, good code?         


Author: yanlinlin
Date: Dec 15, 2007 22:07

On 12月16日, 下午1时49分, George2 yahoo.com> wrote:
> Hello everyone,
>
> I am reading some code from other people, there are some code like
> this,
>
> [Code]
> class Foo {
>
> };
>
> Foo& func()
> {
> Foo foo;
> return foo;
>
> }
>
> int main()
> { ...
Show full article (0.68Kb)
2 Comments
  Re: How does this work without instantiating an object of the Student class?         


Author: tragomaskhalos
Date: Dec 15, 2007 15:14

On 15 Dec, 13:57, Pete Becker versatilecoding.com> wrote:
> On 2007-12-15 04:36:30 -0500, tragomaskhalos
> logicacmg.com> said:
>
>> OK, my original reply wasn't detailed enough.
>> Others have said that this is UB but you are quite correctly
>> still wondering why it happend to work with your compiler.
>> The key is that the compiler is likely producing code something akin
>> to this:
>
> Maybe. Speculating about why something whose behavior is undefined
> happens to do what a naive programmer guessed it would do is generally
> pointless. Undefined means undefined. Nothing more. The reason that it
> "works" is pure accident. (That's the screed for beginning and
> intermediate programmers.)
>
Show full article (1.20Kb)
no comments
  Re: Excuse me!!         


Author: Vladislav.Lazarenko
Date: Dec 15, 2007 10:57

Could you please give me his email? He seems to be a nice guy from
your words. I would like to speak with him. Thanks in advance.
no comments
1 2 3 4 5 6