digitalmars.D.learn - Error: function declaration without return type.
- Suliman (24/24) Jan 06 2015 class Test
- bearophile (4/11) Jan 06 2015 I guess you have to remove that line.
- Suliman (2/13) Jan 06 2015 Why? I can't call function in instance of class?
- =?UTF-8?B?TWFydGluIERyYcWhYXI=?= via Digitalmars-d-learn (6/23) Jan 06 2015 What would that even mean? When would the function ran? If you want to
- ketmar via Digitalmars-d-learn (5/22) Jan 06 2015 On Tue, 06 Jan 2015 21:25:49 +0000
- Suliman (16/16) Jan 07 2015 thanks!
- Tobias Pankrath (3/18) Jan 07 2015 scope(exit) executes at the exit of the inner most scope. Scopes
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (27/42) Jan 07 2015 Instances of classes are objects that are created by 'new'. So, yes, you...
class Test { string mystring; this(string mystring) { this.mystring = mystring; } void foo() { writeln("test"); writeln(mystring); } foo(); } source\app.d(303): Error: function declaration without return type. (Note that c onstructors are always named 'this') source\app.d(303): Error: no identifier for declarator foo() FAIL .dub\build\application-debug-windows-x86-dmd_2066-EF7A441AE01F652132F0A1ED8 B06EB48\ seismodownloader executable Error executing command run: dmd failed with exit code 1. What I am doing wrong?
Jan 06 2015
Suliman:void foo() { writeln("test"); writeln(mystring); } foo(); <<<<< }I guess you have to remove that line. Bye, bearophile
Jan 06 2015
On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote:Suliman:Why? I can't call function in instance of class?void foo() { writeln("test"); writeln(mystring); } foo(); <<<<< }I guess you have to remove that line. Bye, bearophile
Jan 06 2015
Dne 6.1.2015 v 22:25 Suliman via Digitalmars-d-learn napsal(a):On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote:What would that even mean? When would the function ran? If you want to call that function during instantiation, put it into constructor. If you want to call it sometime later, than you have to call it from somewhere else. But having a function call inside a class does not compute... MartinSuliman:=20 Why? I can't call function in instance of class?void foo() { writeln("test"); writeln(mystring); } foo(); <<<<< }I guess you have to remove that line. Bye, bearophile
Jan 06 2015
On Tue, 06 Jan 2015 21:25:49 +0000 Suliman via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote:'cause dlang specs (which you read with a great care, aren't you?) doesn't allow it.Suliman:=20 Why? I can't call function in instance of class?void foo() { writeln("test"); writeln(mystring); } foo(); <<<<< }I guess you have to remove that line. Bye, bearophile
Jan 06 2015
thanks! Am I right understand that in next code scope(exit) stmt.close(); occur after this execution? And it will close connection so stmt in function become unavailable. this(parseConfig parseconfig) { [....] auto conn = ds.getConnection(); scope(exit) conn.close(); stmt = conn.createStatement(); scope(exit) stmt.close(); //HERE } void InsertData() { auto rs = stmt.executeUpdate(sqlinsert); // stmt now unreachable }
Jan 07 2015
On Wednesday, 7 January 2015 at 08:58:35 UTC, Suliman wrote:thanks! Am I right understand that in next code scope(exit) stmt.close(); occur after this execution? And it will close connection so stmt in function become unavailable. this(parseConfig parseconfig) { [....] auto conn = ds.getConnection(); scope(exit) conn.close(); stmt = conn.createStatement(); scope(exit) stmt.close(); //HERE } void InsertData() { auto rs = stmt.executeUpdate(sqlinsert); // stmt now unreachable }scope(exit) executes at the exit of the inner most scope. Scopes end at '}'. Which is the very next line in this case.
Jan 07 2015
On 01/06/2015 01:25 PM, Suliman wrote:> On Tuesday, 6 January 2015 at 21:19:38 UTC, bearophile wrote:Instances of classes are objects that are created by 'new'. So, yes, you can call member functions on instances of classes. There are two instances of Test in the following main(): import std.stdio; class Test { string mystring; this(string mystring) { this.mystring = mystring; } void foo() { writeln("test"); writeln(mystring); } } void main() { auto a = new Test("hello"); auto b = new Test("hi"); a.foo(); b.foo(); } AliSuliman:Why? I can't call function in instance of class?void foo() { writeln("test"); writeln(mystring); } foo(); <<<<< }I guess you have to remove that line. Bye, bearophile
Jan 07 2015