Reputation: 1379
I drew up this sample piece of code to highlight the relevant bits. When the code is compiled:
#include <iostream>
using namespace std;
enum LeaseState {
LEASE_NONE = 0x00,
LEASE_READ_CACHING = 0x01,
LEASE_HANDLE_CACHING = 0x02,
LEASE_WRITE_CACHING = 0x04,
LEASE_RH_CACHING = LEASE_READ_CACHING | LEASE_HANDLE_CACHING,
LEASE_RW_CACHING = LEASE_READ_CACHING | LEASE_WRITE_CACHING,
LEASE_RWH_CACHING = LEASE_READ_CACHING | LEASE_WRITE_CACHING |
LEASE_HANDLE_CACHING
};
LeaseState
updated_lease_state(LeaseState current, LeaseState new)
{
return (new | (current ^ new));
}
int main()
{
cout << "Updated lease state: " << updated_lease_state(LEASE_RW_CACHING, LEASE_READ_CACHING);
cout << "\n";
return 0;
}
...this is the error seen:
$ g++ enum.cc
enum.cc:17: error: expected ‘,’ or ‘...’ before ‘new’
enum.cc: In function ‘LeaseState updated_lease_state(LeaseState, LeaseState)’:
enum.cc:19: error: expected type-specifier before ‘|’ token
enum.cc:19: error: expected type-specifier before ‘)’ token
Can someone help me understand what's wrong with line 17?
Thanks!
Upvotes: 0
Views: 75
Reputation: 1629
new is a reserved keyword!
LeaseState updated_lease_state(LeaseState current, LeaseState newState)
{
return (newState | (current ^ newState));
}
Upvotes: 3