Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-07-2005, 11:00 PM   #1 (permalink)
deepak_kr_mehta
banned
 
deepak_kr_mehta's Avatar
 
Join Date: May 2005
Posts: 23
deepak_kr_mehta is on a distinguished road
some error plz remove

hello sir
sir when i run this following programme it will showing me error.plz assist me to remove it

#include<iostream.h>
#include<conio.h>
class student
{
int id;
mutable int j;//it will showing error 1. declaration missing //2. undefined symbol hpublic:
void set(int i)
{
id=i;
j=90;// cannot modify}
void print()
{
cout<<id<<j;
}
};
void main()
{
student s1;
s1.set(5);
s1.print();
}

sir after place mutable it will showing me same error with extra syntex error.
plz sir correct it.
thanx
from
deepak kr.

Last edited by Valmont; 05-07-2005 at 11:30 PM.
deepak_kr_mehta is offline   Reply With Quote
Old 05-07-2005, 11:43 PM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Experiment with this code:
Code:
#include<iostream>

class student
{
private:
  int id;
  mutable int j;
public:
  student(int id, int j) : id(id), j(j) {}
public:
  void set(int i) const
  {
    j=i;  // can modify
  }

  void print() const
  {
    std::cout<<id<<" "<<j;
  }
};

int main()
{
  const student s1(1,1);
  s1.set(5);
  s1.print();
  
  std::cin.get();
  return 0;
}
Next time, format your code decently so it becomes readable. Also add the code between code tags. In general, READ the sticky topic I posted in the link below:
[READ THIS FIRST] About the standard C++ forum.
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
remove duplicate entries from an array? Admin PHP 3 07-14-2003 12:30 PM


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


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting