Problem #1: Point out the errors(s) if any, in the following program:

``````
1     // Problem related to Operator
3     #include <iostream.h>
4
5     class myclass
6     {
7       int a;
8
9     public:
10      myclass(int);
11      void show();
12
13      myclass operator ++();
14      myclass operator --();
15    };
16
17    myclass::myclass(int x)
18    {
19      a=x;
20    }
21
22    void myclass::show()
23    {
24      cout<<a<<endl;
25    }
26
27    myclass myclass::operator ++()
28    {
29      a++;
30
31      return *this;
32    }
33
34    myclass myclass::operator --()
35    {
36      a--;
37
38      return *this;
39    }
40
41    // main
42    void main()
43    {
44      myclass ob(10);
45
46      ob.show();
47
48      ob++;
49      ob.show();
50    }

``````

Problem #2: Point out the errors(s) if any, in the following program:

``````
1     // Problem related to Operator
3     #include <iostream.h>
4
5     class myclass
6     {
7       int a;
8       int b;
9
10    public:
11      myclass(int, int);
12      void show();
13
14      myclass operator=(myclass);
15    };
16
17    myclass myclass::operator=(myclass ob)
18    {
19      a=ob.a;
20      b=ob.b;
21    };
22
23    myclass::myclass(int x,int y)
24    {
25      a=x;
26      b=y;
27    }
28
29    void myclass::show()
30    {
31      cout<<a<<endl<<b<<endl;
32    }
33
34    // main
35    void main()
36    {
37      myclass ob(10,11);
38      myclass ob2(20,21);
39      myclass ob3(30,41);
40
41      int x,y,z;
42
43      x=y=z=10;
44      cout<<z<<endl;
45
46      ob=ob2=ob3;
47      ob.show();
48    }

``````

Problem #3: Point out the errors(s) if any, in the following program:

``````
1     #include <iostream.h>
2
3     // class
4     class myclass
5     {
6       int a;
7
8     public:
9       myclass(int);
10      void show();
11
12      void operator ++();
13      void operator --();
14    };
15
16    myclass::myclass(int x)
17    {
18      a=x;
19    }
20
21    void myclass::show()
22    {
23      cout<<a<<endl;
24    }
25
26    void myclass::operator ++()
27    {
28        a++;
29    }
30
31    void myclass::operator --()
32    {
33      a--;
34    }
35
36    // main
37    void main()
38    {
39      myclass ob(10);
40      myclass ob2(100);
41
42      ob.show();
43      ob2.show();
44
45      ob2=++ob;
46      ob.show();
47      ob2.show();
48    }

``````

1. Although no error is reported (MS Visual C++) but line number 48 has a problem because postfix version of the operators have not been overloaded. This way the compile uses prefix form instead besides giving warning.

2. ERROR in line number 46. Here ob2=ob3 is first evaluated by the overloaded assignment operator as defined but it is not returning any value which can be further assigned to ob.

3. ERROR in line number 45. Operator function is not returning anything which can be assigned to ob2.

Related Articles:

### Fix For Toshiba Satellite "RTC Battery is Low" Error (with Pictures)

RTC Battery is Low Error on a Toshiba Satellite laptop "RTC Battery is Low..." An error message flashing while you try to boot your laptop is enough to panic many people. But worry not! "RTC Battery" stands for Real-Time Clock battery which almost all laptops and PCs have on their motherboard to power the clock and sometimes to also keep the CMOS settings from getting erased while the system is switched off.  It is not uncommon for these batteries to last for years before requiring a replacement as the clock consumes very less power. And contrary to what some people tell you - they are not rechargeable or getting charged while your computer or laptop is running. In this article, we'll learn everything about RTC batteries and how to fix the error on your Toshiba Satellite laptop. What is an RTC Battery? RTC or CMOS batteries are small coin-shaped lithium batteries with a 3-volts output. Most laptops use

### The Best Way(s) to Comment out PHP/HTML Code

PHP supports various styles of comments. Please check the following example: <?php // Single line comment code (); # Single line Comment code2 (); /* Multi Line comment code(); The code inside doesn't run */ // /* This doesn NOT start a multi-line comment block /* Multi line comment block The following line still ends the multi-line comment block //*/ The " # " comment style, though, is rarely used. Do note, in the example, that anything (even a multi-block comment /* ) after a " // " or " # " is a comment, and /* */ around any single-line comment overrides it. This information will come in handy when we learn about some neat tricks next. Comment out PHP Code Blocks Check the following code <?php //* Toggle line if ( 1 ) {      // } else {      // } //*/ //* Toggle line if ( 2 ) {      // } else {      // } //*/ Now see how easy it is to toggle a part of PHP code by just removing or adding a single " / " from th

### How to Create an HTML Form Linked with MySQL Database in PHP

If you're looking for example code and detailed discussion on how to create an HTML form that stores data in a MySQL database using PHP then this post might be what you're looking for. I assume that you're familiar with basic HTML, CSS, PHP coding, and  MySQL. I am going to divide this small project into two parts: The HTML form itself that takes input from the user and the PHP script that saves it into the database A table that displays the user-added data that has been saved in the database. We'll be dealing with the first part in this tutorial. Again I'd like to break this problem into a few parts so that it's easier for you to understand and probably gives you an insight into how breaking up a problem into smaller chunks can help make things clearer in your mind. Let's think about it, there is an HTML form (that is HTML code), then there is the PHP code that deals with the user-input data, and the MySQL database itself. For this tutorial, we'll b