Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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..




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 09:56 PM
page 167 Issue with Step 10. iPhoneNoob BOOK: Beginning iPhone SDK Programming with Objective-C 1 July 26th, 2010 11:49 AM
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 04: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 05: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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.