I am very very new to C++. This is a code that I wrote in vb.NET previously.
This is a button click command:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Dim p As New List(Of Long)
k = 3
m = 2
p.Add(m)
For n = 1 To k
For l = 0 To n
If m Mod p(l) = 0 Then
m = m + 1
End If
Next l
p.Add(m)
Next n
Beep()
Me.TextBox2.Text = m
I tried:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
std::list<int> p;
int k = 3;
int m = 2;
p.push_back(m);
for( int n = 1; n < k; n++ ) {
for( int l = 0; l < n; l++ ) {
if ( m % p(l) == 0 );
{
m = m + 1;
};
};
p.push_back(m);
};
System::String^ b = m.ToString();
textBox2->Text = b;
};
I am sure I am using functions wrong like "push_back".
Ofcourse it's not working. Can you help me?
Thanks a lot!
Same line: if (m % p[l] == 0)Now, it is underlining p again and saying:
"expression must have pointer-to-object or handle-to-C++/CLI-array type"
And also:
"binary '[' : 'std::list<_Ty>' does not define this operator or a conversion to a type acceptable to the predefined operator"
Error for the whole line.