Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Ivor Horton's Beginning Visual C++ 2013
This is the forum to discuss the Wrox book Ivor Horton's Beginning Visual C++ 2013 by Ivor Horton; ISBN: 978-1-118-84571-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Ivor Horton's Beginning Visual C++ 2013 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 10th, 2018, 08:33 AM
Tez Tez is offline
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: London, London, United Kingdom.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 10 - EX10_07 Issue

Hi, I'm sure I've typed something wrong but when trying to complied this example, I get:

1>c:\users\terry\onedrive\documents\tech stuff\programming\c++\ex10_07\ex10_07\function_obj ect.h(8): error C2143: syntax error: missing ';' before '('


I've copied the code from the download in case there was something I just wasn't seeing but get the same error.


Any ideas anyone? Is it a difference between versions? I'm using VS 2017 Community (all updates applied) on Win 10.


The code for function_object. h is:


Code:
#pragma once
#include <functional>

template <class T> class is_negative : public std::unary_function<T , bool>
{
public:
    result_type operator()(argument_type& value)
    {
        return value < 0;
    }
};
It's being called like this:


Code:
    // Process integers
    std::list<int> numbers;
    cout << "Enter non-zero integers separated by spaces. Enter 0 to end."
        << endl;
    loadList(numbers);
    cout << "The list contains:" << endl;
    listAll(numbers);

    numbers.remove_if(is_negative<int>());
    cout << "After applying remove_if() the list contains:" << endl;
    listAll(numbers);

UPDATE: Strangely, all works fine if I replace the base template class references as so:


Code:
template <class T> class is_negative
{
public:
    bool operator()(const T& value)
    {
        return value < 0;
    }
};

Last edited by Tez; November 10th, 2018 at 03:04 PM.
Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10 minor issue with the Class library notig BOOK: Beginning Visual C# 2010 0 September 26th, 2010 10:56 PM
page 167 Issue with Step 10. iPhoneNoob BOOK: Beginning iPhone SDK Programming with Objective-C 1 July 26th, 2010 12:49 PM
Chapter 10, listing 10-10-app kiwibrit BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 2 August 18th, 2009 05:21 AM
Chapter 10: Referencing CSS issue tomche BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 3 April 26th, 2009 06:54 AM
Chapter 10 charedit.php issue luke adamis BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 January 1st, 2006 06:28 PM



All times are GMT -4. The time now is 08:57 AM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.