This repository has been archived by the owner on Nov 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from vanshitaverma/main
Improving error messages
- Loading branch information
Showing
3 changed files
with
47 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,16 @@ | ||
To define a class use the following syntax | ||
Error #2: Syntax error in the class definition | ||
|
||
class name: | ||
"Your code here" | ||
Example: | ||
To define a class, use the following syntax: | ||
|
||
To define a class with multiple inheritance use the following syntax | ||
class <name>: | ||
[Your code here] | ||
|
||
class name(object1,object2): | ||
"Your code here" | ||
To define a class with multiple inheritance, use the following syntax: | ||
|
||
class <name>(<object1>,<object2>): | ||
[Your code here] | ||
|
||
In the above examples: | ||
1. Text written between <> is changeable as per requirement. | ||
2. Code goes between []. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
A class can only contain variable or methods or nested class/union or enum | ||
Error #3: Class contains something other than variables, methods, nested class/union or enum. | ||
|
||
Example:- | ||
class iterate_test: | ||
variable:int=0 | ||
class nested_class: | ||
... | ||
enum nested_enum: | ||
a,b,c | ||
union nested_union: | ||
x:int | ||
y:float | ||
def __init__(self,c): | ||
... | ||
A class can only contain variable or methods or nested class/union or enum. | ||
|
||
Example: | ||
class iterate_test: | ||
int <variable_name> = 0; | ||
|
||
class <nested_class>: | ||
[Your code here] | ||
|
||
enum <nested_enum>: | ||
a,b,c | ||
|
||
union <nested_union>: | ||
x:int | ||
y:float | ||
|
||
def __init__(self,c): | ||
[Your code here] | ||
|
||
In the above example: | ||
1. Text written between <> is changeable as per requirement. | ||
2. Code goes between []. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
A virtual function can be declared inside a class only. Here is an example:- | ||
Error #4: Virtual function cannot be declared outside the class. | ||
|
||
class name: | ||
virtual __init__(self): | ||
... | ||
A virtual function can only be declared inside a class. | ||
|
||
Example: | ||
class <name>: | ||
virtual __init__(self): | ||
[Your code here] | ||
|
||
In the above example: | ||
1. Text written between <> is changeable as per requirement. | ||
2. Code goes between []. |