Skip to content
This repository has been archived by the owner on Nov 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #137 from vanshitaverma/main
Browse files Browse the repository at this point in the history
Improving error messages
  • Loading branch information
SaptakBhoumik authored Oct 24, 2022
2 parents 3360a30 + 2622d95 commit 07a6a72
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 23 deletions.
19 changes: 13 additions & 6 deletions error_help/e2.txt
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 [].
36 changes: 23 additions & 13 deletions error_help/e3.txt
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 [].
15 changes: 11 additions & 4 deletions error_help/e4.txt
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 [].

0 comments on commit 07a6a72

Please sign in to comment.